<s> """<STR_LIT>""" <EOL> from . base import MySQLDialect , MySQLExecutionContext <EOL> from ... connectors . pyodbc import PyODBCConnector <EOL> from ... import util <EOL> import re <EOL> class MySQLExecutionContext_pyodbc ( MySQLExecutionContext ) : <EOL> def get_lastrowid ( self ) : <EOL> cursor = self . create_cursor ( ) <EOL> cursor . execute ( "<STR_LIT>" ) <EOL> lastrowid = cursor . fetchone ( ) [ <NUM_LIT:0> ] <EOL> cursor . close ( ) <EOL> return lastrowid <EOL> class MySQLDialect_pyodbc ( PyODBCConnector , MySQLDialect ) : <EOL> supports_unicode_statements = False <EOL> execution_ctx_cls = MySQLExecutionContext_pyodbc <EOL> pyodbc_driver_name = "<STR_LIT>" <EOL> def __init__ ( self , ** kw ) : <EOL> kw . setdefault ( '<STR_LIT>' , True ) <EOL> super ( MySQLDialect_pyodbc , self ) . __init__ ( ** kw ) <EOL> def _detect_charset ( self , connection ) : <EOL> """<STR_LIT>""" <EOL> rs = connection . execute ( "<STR_LIT>" ) <EOL> opts = dict ( [ ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:1> ] ) for row in self . _compat_fetchall ( rs ) ] ) <EOL> for key in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if opts . get ( key , None ) : <EOL> return opts [ key ] <EOL> util . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> return '<STR_LIT>' <EOL> def _extract_error_code ( self , exception ) : <EOL> m = re . compile ( r"<STR_LIT>" ) . search ( str ( exception . args ) ) <EOL> c = m . group ( <NUM_LIT:1> ) <EOL> if c : <EOL> return int ( c ) <EOL> else : <EOL> return None <EOL> dialect = MySQLDialect_pyodbc </s>
