Skip to content

Export data from a csv file into a mysql database

License

Notifications You must be signed in to change notification settings

Anzo52/csv2mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csv2mysql

Status GitHub Issues GitHub Pull Requests License


Python script to convert csv files to mysql database tables.

📝 Table of Contents

🧐 About

This project is a python script to convert csv files to mysql database tables. Only tested on Linux, LMDE 5, Debian 10.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

As stated in Getting Started, this project was only tested on Linux, LMDE 5, Debian 10, so built-in tools may not be available on other systems. Please create an issue if you have any problems. Other than that, you'll need to install the following dependencies (you'll find step-by-step instructions for the Python packages in the Installing section below):

  • Python 3.7 or higher
  • pip (Python package manager) <-- I used debian's package manager to install this
  • Python packages:
    • sqlalchemy
    • pandas
    • numpy
  • MySQL server (version 8.0.23) <-- I used debian's package manager to install this
  • MySQL Workbench (version 8.0.23) <-- I used debian's package manager to install this

It is recommended to use a virtual environment to install the dependencies. The following instructions will install the dependencies in a virtual environment. You should also have a MySQL server running on your machine. You can download it from here. Instructions for setting up a MySQL server can be found here.

Installing and Using

Here's a list of the installation steps required to get the project up and running, it's assumed that you already have Python 3.7 or higher, pip, and venv installed. If you don't, please refer to the Prerequisites section above or the Python documentation:

  1. Clone the repository and cd into the project directory

  2. Create and activate a virtual environment

  3. Install the dependencies

  4. Create a MySQL database

  5. Run the script

  6. Clone the repository and cd into the project directory

git clone https://github.com/Anzo52/csv2mysql.git
cd csv2mysql
  1. Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
  1. Install the dependencies
pip install -r requirements.txt
  1. Create a MySQL database
mysql -u root -p
CREATE DATABASE [database_name];
  1. Run the script (you'll be prompted to enter the database name, username, and password. Make sure to use the same database name you used in step 4)
python3 csv2mysql.py

⛏️ Built Using

  • Python - Programming language
  • pandas - Data analysis and manipulation tool
  • numpy - Scientific computing package
  • sqlalchemy - SQL toolkit and Object Relational Mapper

Releases

No releases published

Packages

No packages published

Languages