/MySql-Python-Import-Script

Python script for importing data from .csv, .xls, or .xlsx to MySQL database.

Primary LanguagePythonMIT LicenseMIT

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

Setup

$ virtualenv <envname> -p python3
$ source <envname>/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