<s> """<STR_LIT>""" <EOL> from ... import util <EOL> from ... import types as sqltypes <EOL> from . base import PGDialect , PGExecutionContext <EOL> from ... import processors <EOL> class PGNumeric ( sqltypes . Numeric ) : <EOL> def bind_processor ( self , dialect ) : <EOL> return processors . to_str <EOL> def result_processor ( self , dialect , coltype ) : <EOL> if self . asdecimal : <EOL> return None <EOL> else : <EOL> return processors . to_float <EOL> class PGExecutionContext_pypostgresql ( PGExecutionContext ) : <EOL> pass <EOL> class PGDialect_pypostgresql ( PGDialect ) : <EOL> driver = '<STR_LIT>' <EOL> supports_unicode_statements = True <EOL> supports_unicode_binds = True <EOL> description_encoding = None <EOL> default_paramstyle = '<STR_LIT>' <EOL> supports_sane_rowcount = True <EOL> supports_sane_multi_rowcount = False <EOL> execution_ctx_cls = PGExecutionContext_pypostgresql <EOL> colspecs = util . update_copy ( <EOL> PGDialect . colspecs , <EOL> { <EOL> sqltypes . Numeric : PGNumeric , <EOL> sqltypes . Float : sqltypes . Float , <EOL> } <EOL> ) <EOL> @ classmethod <EOL> def dbapi ( cls ) : <EOL> from postgresql . driver import dbapi20 <EOL> return dbapi20 <EOL> def create_connect_args ( self , url ) : <EOL> opts = url . translate_connect_args ( username = '<STR_LIT:user>' ) <EOL> if '<STR_LIT:port>' in opts : <EOL> opts [ '<STR_LIT:port>' ] = int ( opts [ '<STR_LIT:port>' ] ) <EOL> else : <EOL> opts [ '<STR_LIT:port>' ] = <NUM_LIT> <EOL> opts . update ( url . query ) <EOL> return ( [ ] , opts ) <EOL> def is_disconnect ( self , e , connection , cursor ) : <EOL> return "<STR_LIT>" in str ( e ) <EOL> dialect = PGDialect_pypostgresql </s>
