<s> """<STR_LIT>""" <EOL> from . base import ( MySQLDialect , MySQLExecutionContext , <EOL> MySQLCompiler , MySQLIdentifierPreparer , <EOL> BIT ) <EOL> from ... import util <EOL> import re <EOL> class MySQLExecutionContext_mysqlconnector ( MySQLExecutionContext ) : <EOL> def get_lastrowid ( self ) : <EOL> return self . cursor . lastrowid <EOL> class MySQLCompiler_mysqlconnector ( MySQLCompiler ) : <EOL> def visit_mod_binary ( self , binary , operator , ** kw ) : <EOL> if self . dialect . _mysqlconnector_double_percents : <EOL> return self . process ( binary . left , ** kw ) + "<STR_LIT>" + self . process ( binary . right , ** kw ) <EOL> else : <EOL> return self . process ( binary . left , ** kw ) + "<STR_LIT>" + self . process ( binary . right , ** kw ) <EOL> def post_process_text ( self , text ) : <EOL> if self . dialect . _mysqlconnector_double_percents : <EOL> return text . replace ( '<STR_LIT:%>' , '<STR_LIT>' ) <EOL> else : <EOL> return text <EOL> def escape_literal_column ( self , text ) : <EOL> if self . dialect . _mysqlconnector_double_percents : <EOL> return text . replace ( '<STR_LIT:%>' , '<STR_LIT>' ) <EOL> else : <EOL> return text <EOL> class MySQLIdentifierPreparer_mysqlconnector ( MySQLIdentifierPreparer ) : <EOL> def _escape_identifier ( self , value ) : <EOL> value = value . replace ( self . escape_quote , self . escape_to_quote ) <EOL> if self . dialect . _mysqlconnector_double_percents : <EOL> return value . replace ( "<STR_LIT:%>" , "<STR_LIT>" ) <EOL> else : <EOL> return value <EOL> class _myconnpyBIT ( BIT ) : <EOL> def result_processor ( self , dialect , coltype ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> class MySQLDialect_mysqlconnector ( MySQLDialect ) : <EOL> driver = '<STR_LIT>' <EOL> supports_unicode_binds = True <EOL> supports_sane_rowcount = True <EOL> supports_sane_multi_rowcount = True <EOL> supports_native_decimal = True <EOL> default_paramstyle = '<STR_LIT>' <EOL> execution_ctx_cls = MySQLExecutionContext_mysqlconnector <EOL> statement_compiler = MySQLCompiler_mysqlconnector <EOL> preparer = MySQLIdentifierPreparer_mysqlconnector <EOL> colspecs = util . update_copy ( <EOL> MySQLDialect . colspecs , <EOL> { <EOL> BIT : _myconnpyBIT , <EOL> } <EOL> ) <EOL> @ util . memoized_property <EOL> def supports_unicode_statements ( self ) : <EOL> return util . py3k or self . _mysqlconnector_version_info > ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> @ classmethod <EOL> def dbapi ( cls ) : <EOL> from mysql import connector <EOL> return connector <EOL> def create_connect_args ( self , url ) : <EOL> opts = url . translate_connect_args ( username = '<STR_LIT:user>' ) <EOL> opts . update ( url . query ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , bool ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , bool ) <EOL> opts . setdefault ( '<STR_LIT>' , True ) <EOL> if self . dbapi is not None : <EOL> try : <EOL> from mysql . connector . constants import ClientFlag <EOL> client_flags = opts . get ( <EOL> '<STR_LIT>' , ClientFlag . get_default ( ) ) <EOL> client_flags |= ClientFlag . FOUND_ROWS <EOL> opts [ '<STR_LIT>' ] = client_flags <EOL> except Exception : <EOL> pass <EOL> return [ [ ] , opts ] <EOL> @ util . memoized_property <EOL> def _mysqlconnector_version_info ( self ) : <EOL> if self . dbapi and hasattr ( self . dbapi , '<STR_LIT>' ) : <EOL> m = re . match ( r'<STR_LIT>' , <EOL> self . dbapi . __version__ ) <EOL> if m : <EOL> return tuple ( <EOL> int ( x ) <EOL> for x in m . group ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> if x is not None ) <EOL> @ util . memoized_property <EOL> def _mysqlconnector_double_percents ( self ) : <EOL> return not util . py3k and self . _mysqlconnector_version_info < ( <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> def _get_server_version_info ( self , connection ) : <EOL> dbapi_con = connection . connection <EOL> version = dbapi_con . get_server_version ( ) <EOL> return tuple ( version ) <EOL> def _detect_charset ( self , connection ) : <EOL> return connection . connection . charset <EOL> def _extract_error_code ( self , exception ) : <EOL> return exception . errno <EOL> def is_disconnect ( self , e , connection , cursor ) : <EOL> errnos = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> exceptions = ( self . dbapi . OperationalError , self . dbapi . InterfaceError ) <EOL> if isinstance ( e , exceptions ) : <EOL> return e . errno in errnos or "<STR_LIT>" in str ( e ) <EOL> else : <EOL> return False <EOL> def _compat_fetchall ( self , rp , charset = None ) : <EOL> return rp . fetchall ( ) <EOL> def _compat_fetchone ( self , rp , charset = None ) : <EOL> return rp . fetchone ( ) <EOL> _isolation_lookup = set ( [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> def _set_isolation_level ( self , connection , level ) : <EOL> if level == '<STR_LIT>' : <EOL> connection . autocommit = True <EOL> else : <EOL> connection . autocommit = False <EOL> super ( MySQLDialect_mysqlconnector , self ) . _set_isolation_level ( <EOL> connection , level ) <EOL> dialect = MySQLDialect_mysqlconnector </s>
