A Python CLI tool to load data from a CSV file into a MySQL database table using convention over configuration.
- Parse and process CSV files efficiently using Pandas.
- Convention over Configuration: The database table name is automatically inferred from the CSV filename (e.g.,
users.csvwill load into theuserstable). - Environment variable support for secure database credentials.
- Global terminal command execution after installation.
Clone the repository and install it using pip:
git clone https://github.com/relson/mysql-csv-load.git
cd mysql-csv-load
pip install .
The application uses python-dotenv to manage database credentials. Create a .env file in your working directory with the following variables:
MYSQL_CSV_LOAD_HOST=localhost
MYSQL_CSV_LOAD_USER=your_user
MYSQL_CSV_LOAD_PASSWORD=your_password
MYSQL_CSV_LOAD_DATABASE=your_database_name
MYSQL_CSV_LOAD_PORT=your_database_port # 3306 when empty or not setAfter installation, the package registers a global command mysql-csv-load. Simply provide the path to your CSV file:
mysql-csv-load path/to/your/customers.csv
How it works: The command above will automatically parse
customers.csvand attempt to load its content into a MySQL table namedcustomers.