All Projects → gyli → DictMySQL

gyli / DictMySQL

Licence: MIT license
More convenient database manipulation with Python dictionary.

Programming Languages

python
139335 projects - #7 most used programming language

DictMySQL

PyPI page: https://pypi.python.org/pypi/dictmysql

Documentation: https://git.io/dictmysql

Introduction

DictMySQL is a MySQL query builder on the top of PyMySQL. It allows convenient database manipulation with Python dictionary.

DictMySQL simplifies and unifies the input/output of MySQL queries, by allowing passing values and conditions in dictionary into database. With DictCursor, you can even have a dict-in, dict-out mysql connector.

To install:

pip install dictmysql

Quick example:

from dictmysql import DictMySQL
db = DictMySQL(db='occupation', host='127.0.0.1', user='root', passwd='')

db.select(table='jobs',
          columns=['id','value'],
          where={'$OR': [{'value': {'$LIKE': 'Artist%'}}, {'id': 10}]})
# SELECT `id`, `value` FROM `jobs` WHERE (`value` LIKE "Artist%") OR (`id` = 10);

With DictCursor:

from dictmysql import DictMySQL, cursors
db = DictMySQL(db='occupation', host='127.0.0.1', user='root', passwd='',
               cursorclass=cursors.DictCursor)

db.select(table='jobs',
          columns=['id','value'],
          limit=2)
# returns [{u'id': 1, u'value': u'Artist'}, {u'id': 2, u'value': u'Engineer'}]

Future Works

  1. Full support of CRUD
  2. Better documents

License

DictMySQL uses the MIT license, see LICENSE file for the details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].