Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sartim/mysql-python-import-script
Python script for importing data from .csv, .xls, or .xlsx to MySQL database.
https://github.com/sartim/mysql-python-import-script
importer mysql-connector-python python python-script xlrd
Last synced: about 2 months ago
JSON representation
Python script for importing data from .csv, .xls, or .xlsx to MySQL database.
- Host: GitHub
- URL: https://github.com/sartim/mysql-python-import-script
- Owner: sartim
- License: mit
- Created: 2015-08-12T07:57:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-21T05:56:44.000Z (over 3 years ago)
- Last Synced: 2023-03-02T00:50:37.391Z (almost 2 years ago)
- Topics: importer, mysql-connector-python, python, python-script, xlrd
- Language: Python
- Homepage:
- Size: 33.2 KB
- Stars: 10
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MySql-Python-Import-Script
Python script for importing data from .csv, .xls, or .xlsx to MySql database. It requires the headers to run an insert
query to database using the headers as the fields.## Setup
**Requirements**
* [python 2+](https://www.python.org)
* [virtualenv](https://virtualenv.pypa.io/en/latest/)
* [mysql-connector-python](https://dev.mysql.com/doc/connector-python/en/connector-python-introduction.html)
* [xlrd](https://xlrd.readthedocs.io/en/latest/)**Setup**
$ virtualenv -p python3
$ source /bin/activate
$ pip install -r requirements.txt**Running script**
$ python import.py -h
$ python import.py -t spreadsheet -f data/users.xlsx -s source -H hostname.com -U username -P pwd -D db_name
$ python import.py -t csv -f data/users.csv -H hostname.com -U username -P pwd -D db_name
###### arguments
_-t (type)_
spreadsheet, csv_-f (file)_
Path to dataset file
_-s (sheet name)_
Used if the dataset type in use is a spreadsheet
_-H (host name)_
Database host name
_-U (username)_
Database username
_-P (password)_
Database password
_-D (database name)_
Database name