Skip to content

The most basic mysql python package around based on mysql-connector.

License

Notifications You must be signed in to change notification settings

messer979/mysql-funk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mysql-funk

Querying and updating a MySQL database in Python doesn't get any easier than this. This package was created because the mysql-connector is too convoluted to use on the fly. For a quick data recording job, I didn't want to worry about opening and closing connections and cursors. Other packages like SQLAlchemy were not my preference because I'm comfortable with SQL. Some packages try to get rid of the SQL which just isn't a problem for me.

So to put a fine point on it - this package is created for one who knows SQL.

I maintain my DB on the server and just want python to add records periodically or post results to a web app/report. This package works great as a simple solution to do just that. I call it funk because it's care free, smooth, and relaxed. The learning curve is small.

pip install MysqlFunk

Step 1: Enter the DB connection info

dbconfig = {
        'user': 'main',
        'password': '',
        'host': '127.0.0.1',
        'database': 'army_knife'
            }

Step 2: Startup the MysqlFunk class

from MysqlFunk.MysqlFunk import MysqlFunk
my_db = MysqlFunk(**dbconfig)

Step 3: Update or insert

insert = "insert into test (date_time,text,text2) values (now(),'test','test')"
my_db.commit_statement(insert)

Step 4: Query away

select = "select * from test"
results = my_db.query_statement(select)

Results always come back as a list of tuples. Each tuple is a row from the DB.

About

The most basic mysql python package around based on mysql-connector.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages