Skip to main content

MySQL for Gevent kept Simple.

Project description


# pip install my4geks
import gevent.monkey ; gevent.monkey.patch_all()
from my4geks import db, db_config, db_transaction

db_config.update(user='user', password='password', database='test')
    # Defaults: host='', port=3306, pool_size=10, query_timeout=55, charset='utf8', cursor_class=AdictCursor.

def on_request(): # Inside a greenlet:

    item = db('SELECT * FROM `items` WHERE `id` = %s', item_id, charset='utf8mb4').row

    for item in db('SELECT `id`, `name` FROM `items` WHERE `name` IN %s, [value1, value2]).rows:
        print('{}   {}'.format(,

    assert db('UPDATE `items` SET `name` = %s WHERE `name` = %s', new_value, old_value).affected # rowcount

    def code():
        db('INSERT INTO `table1` (`quantity`) VALUES (%s)', -100)
        db('INSERT INTO `table2` (`quantity`) VALUES (%s)', +1/0)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for my4geks, version 0.1.6
Filename, size File type Python version Upload date Hashes
Filename, size my4geks-0.1.6.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page