@@ -40,6 +40,9 @@ def __init__(self, url, kwargs):
4040 self .queue = queue .Queue ()
4141 self .thread = None
4242
43+ def update_url (self , url ):
44+ return url .difference_update_query (["dbcounter" ])
45+
4346 def engine_created (self , engine ):
4447 """Hook the engine creation process.
4548
@@ -77,12 +80,12 @@ def _log_event(self, conn, cursor, statement, parameters, context,
7780 def do_incr (self , db , op , count ):
7881 """Increment the counter for (db,op) by count."""
7982
80- query = ('INSERT INTO queries (db, op, count) '
81- ' VALUES (%s, %s, %s ) '
82- ' ON DUPLICATE KEY UPDATE count=count+%s ' )
83+ query = sqlalchemy . text ('INSERT INTO queries (db, op, count) '
84+ ' VALUES (:db, :op, :count ) '
85+ ' ON DUPLICATE KEY UPDATE count=count+:count ' )
8386 try :
8487 with self .engine .begin () as conn :
85- r = conn .execute (query , ( db , op , count , count ) )
88+ r = conn .execute (query , { 'db' : db , 'op' : op , ' count' : count } )
8689 except Exception as e :
8790 LOG .error ('Failed to account for access to database %r: %s' ,
8891 db , e )
0 commit comments