Performance
SQLNumResultCols On Demand
Currently, SQLNumResultCols and SQLNumResultCols are both called after every execute. However, the actual rowcount is very seldom used, so we could call it the first time Cursor.rowcount is accessed.
We'll probably need to call SQLNumResultCols to find out if there are results to fetch, though we could try to eliminate that if we see that the SQL starts with INSERT or UPDATE.
PEP 249 states that an interface may support several different parameter marker formats including 'qmark', 'format', and 'pyformat'. I currently use regular expressions to convert the 'format' and 'pyformat' parameter style to 'qmark' before calling the cursor.execute method.
import re def qmark_sql(sql): pattern = "%(\(\w+\))?s" qmark = re.sub(pattern, "?", sql) return qmarkThe 'pyformat' parameter style must convert a dictionary to a tuple of values for use with the cursor.execute method.
import re def qmark_param(sql, d): items = [] pattern = "%(\(\w+\))?s" for m in re.finditer(pattern, sql): # The regular expression group includes the enclosing parenthesis, # which are removed by the [1:-1] index range. key = m.group(1)[1:-1] items.append(d[key]) return tuple(items)http://anekajaringmurah.blogspot.com/ http://pusatjaringmurah.blogspot.com/ http://anekajaringpengaman.blogspot.com/ http://agenjaringpengaman.blogspot.com/ http://jaringpengamanfutsal.blogspot.com/ http://jaring-pengamanmurah.blogspot.com/ http://jaringcenter.blogspot.com/ http://agenjaringjakata.blogspot.com/ http://jualjaringpengamanmurah.blogspot.com/ http://jaringsafetyjakarta.blogspot.com/ http://jaringpengaman-murah.blogspot.com/ http://jaringmurah.blogspot.com/ http://jaring-murah.blogspot.com/ http://jaringpengamanmurah.blogspot.com/ http://jaringbangunan.blogspot.com/ http://agenjaringsafety.blogspot.com/ http://sentral-jaring.blogspot.com/ http://sentraljaring.blogspot.com/ http://tokojaringpengaman.blogspot.com/ http://pusatjaringjakarta.blogspot.com/ http://tokojaringpengamanmurah.blogspot.com/ http://jualjaringsafetymurah.blogspot.com/ https://pancasamudera.wordpress.com/ https://pasangjaringfutsal.wordpress.com/ https://jualtambangmurah.wordpress.com/ https://tokojaring.wordpress.com/ https://jualjaringfutsal.wordpress.com/ https://jaringfutsal.wordpress.com/