Skip to content

tmdag/dbconnector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python 3 MySQL 8 DB manager

VFX Pipeline MySQL v8.0 python v3.6 pylint Score

GitHub: https://github.com/tmdag/dbconnector

Overview

This python script is using official MySQL python connector from MySQL connector website. While official python module is using 'low level' MySQL querries, this dbmanager wraps them around to more pythonic functions.

Installation:

$ pip install git+https://github.com/tmdag/dbconnector

Config file :

dbconnector expects configuration file with your database details. Example of such config: config.ini

[mysql]
user = myusername
password = MySectetPassword
host = myServer
database = myDatabase

You can pass config location to the class as an argument.

Connection :

Each connection with database is made by creating class instance and requires database closure with 'close_connection()' method.

Todo:

  • Support for single file DB
  • more sophisticated calls
  • implement as_dict / as_list

Example:

from dbconnector import dbmanager
db_config = 'config/config.ini'
dbconnect = dbmanager.Connect(cfg=db_config)

db_tables = dbconnect.show_tables()
my_column_names = dbconnect.get_column_names("myTable")
primary_key_of_table = dbconnect.get_primary_key("myTable")
id_of_specific_entry = dbconnect.get_value_id("cameras", "cameraName", "GoPro")
raw_mysql_call = dbconnect.raw_call("SELECT shots.shotName FROM shots INNER JOIN shows ON shows.showID = shots.shows_showID WHERE shows.showName = 'MYSHOT'")

dbconnect.save() # save (commit) if there were any changes made in the database.
dbconnect.close_connection()

About

Python 3 MySQL 8 DB manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages