Skip to main content

Simple PyMySQL ProxyCursor

Project description


A simple cursor wrapper to support before/after processing using PyMySQL.


The last stable release is available on PyPI and can be installed with pip:

$ pip install PyMySQLProxyCursor


from __future__ import print_function

import pymysql
import proxycursor

class SimpleProxy(object):
    def __init__(self):
        self.tblname = 'user'

    def after_insert(self, **kwargs):
        cur = kwargs['cursor']
        cur.execute('SELECT LAST_INSERT_ID()')

    def after_update(self, **kwargs):
        cur = kwargs['cursor']
        cur.execute('SELECT * FROM user ORDER BY updated_at desc LIMIT 1')

conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='', db='mysql')

cur = conn.cursor()
cur = proxycursor.wrap(cur, handlers=[SimpleProxy()])
cur.execute("SELECT Host,User FROM user")



for row in cur:



PyMySQLProxyCursor is released under the MIT License. See LICENSE for more information.

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 PyMySQLProxyCursor, version 0.2.5
Filename, size File type Python version Upload date Hashes
Filename, size PyMySQLProxyCursor-0.2.5.tar.gz (6.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