MySQLPandas

MySQLPandas: simple connector between MySQL(MariaDB) and Pandas


Keywords
Python, Pandas, Database
License
GPL-2.0
Install
pip install MySQLPandas==0.0.19

Documentation

MySQLPandas

pages-build-deployment Version PyPI License: GPL v2

Overview

Simple connector between MySQL(MariaDB) and Pandas

Description

This tool is primarily intended to help Python users easily handle databases. It uses Pandas as its base, so it should be easy to use even for those who are not familiar with databases. The tool supports MySQL or MariaDB as the database engine.

Demo

  • Make new table and install dataframe or csv
from MySQLPandas.core import MySQLPandas
with MySQLPandas("hoge","hoge_db",initfile_path="hoge.ini") as obj:
    obj.makeTable("sample_table",df_path="sample.csv")
    obj.showTableinfo("sample_table")
    obj.insertRecord("sample_table",df_path="sample.csv")

Regarding other functions, see here.

Note

In MySQLPandas function of insertRecord, it doesn't allow any difference on table denfinition.(If it has slightly differcence, MySQLPandas raise error.)

raise PandasMySQLError("Not match Table frame")
MySQLPandas.lib.ErrorClass.PandasMySQLError: Not match Table frame

If you want to change table definition, please see below.

  • Change string type column
    You can change table denfiniton automatically. Please rewrite "Strict_Mode = False" in "insertRecord" method.
  • Change int or float type column
    Sorry, you can't change it in MySQLPandas. Please rewrite it by using "executeSQLcommand" method.

Setup password.ini

In default, you need to input DB password in your console every time.
If you felt bothered, you avoid this by creating "password.ini" file.
In GitHub page, it's put sample file.

Requirement

  • MySQL(MariaDB)
    The version of Auther's MariaDB is 5.5.68-MariaDB MariaDB Server.
    Don't try the newest version so please check your MariaDB version.
  • Pandas <= 1.5.3
  • Python 3.*
  • mysql-connector-python <= 8.0.29
  • tqdm <= 4.65.0

Developer Guide

See here.

Install

Install through pip.

pip install MySQLPandas

Licence

GNU GPLv2

Author

Sota Nakashima