Skip to content

relson/mysql-csv-load

Repository files navigation

mysql-csv-load

A Python CLI tool to load data from a CSV file into a MySQL database table using convention over configuration.

Features

  • 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.csv will load into the users table).
  • Environment variable support for secure database credentials.
  • Global terminal command execution after installation.

Installation

From local source

Clone the repository and install it using pip:

git clone https://github.com/relson/mysql-csv-load.git
cd mysql-csv-load
pip install .

Configuration

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 set

Usage

After 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.csv and attempt to load its content into a MySQL table named customers.

About

Python script to load data from a CSV file into a MySQL database table.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages