mysql-utils

A simple MySQL library including a set of utility APIs for Python database programming


Keywords
mysql, API, utility
License
Unlicense
Install
pip install mysql-utils==0.0.1

Documentation

mysql-utils

A simple MySQL library including a set of utility APIs for Python database programming. It encapsulates MySQL commands into Pythonic functions to make MYSQL operation easier and code more simplified.

Installation

pip install mysql-utils

or

python setup.py install

Usage

APIs provided by mysql-utils include:

  • execute_mysql_cmd
  • delete_table_row
  • get_table_column_value
  • get_multi_columns_given_multi_keys
  • get_table_row
  • set_table_column_value
  • set_table_multi_column_values
  • set_table_column_value_given_multi_keys
  • set_table_multi_column_values_given_multi_keys
  • insert_table_row_from_dict
  • insert_or_update_table_row
  • insert_or_update_row_given_multi_keys

One example of updating and querying table column is as below

In [5]: import mysql_utils

In [6]: msu = mysql_utils.MySQLUtils(database="mcd")

In [7]: msu.get_table_row("mrs", "url", "https://gitlabe2.net.com/component/merge_requests/1321")["author"]
Out[7]: u'pqian'

In [8]: msu.insert_or_update_table_row("mrs", {"url":"https://gitlabe2.net.com/component/merge_requests/1321", "author":"shelwin"},
   ...:  "url")

In [9]: msu.get_table_row("mrs", "url", "https://gitlabe2.net.com/component/merge_requests/1321")["author"]
Out[9]: u'shelwin'

LISENSE

MIT