<s> """<STR_LIT>""" <EOL> from sqlalchemy . dialects . sqlite . base import SQLiteDialect , DATETIME , DATE <EOL> from sqlalchemy import exc , pool <EOL> from sqlalchemy import types as sqltypes <EOL> from sqlalchemy import util <EOL> import os <EOL> class _SQLite_pysqliteTimeStamp ( DATETIME ) : <EOL> def bind_processor ( self , dialect ) : <EOL> if dialect . native_datetime : <EOL> return None <EOL> else : <EOL> return DATETIME . bind_processor ( self , dialect ) <EOL> def result_processor ( self , dialect , coltype ) : <EOL> if dialect . native_datetime : <EOL> return None <EOL> else : <EOL> return DATETIME . result_processor ( self , dialect , coltype ) <EOL> class _SQLite_pysqliteDate ( DATE ) : <EOL> def bind_processor ( self , dialect ) : <EOL> if dialect . native_datetime : <EOL> return None <EOL> else : <EOL> return DATE . bind_processor ( self , dialect ) <EOL> def result_processor ( self , dialect , coltype ) : <EOL> if dialect . native_datetime : <EOL> return None <EOL> else : <EOL> return DATE . result_processor ( self , dialect , coltype ) <EOL> class SQLiteDialect_pysqlite ( SQLiteDialect ) : <EOL> default_paramstyle = '<STR_LIT>' <EOL> colspecs = util . update_copy ( <EOL> SQLiteDialect . colspecs , <EOL> { <EOL> sqltypes . Date : _SQLite_pysqliteDate , <EOL> sqltypes . TIMESTAMP : _SQLite_pysqliteTimeStamp , <EOL> } <EOL> ) <EOL> if not util . py2k : <EOL> description_encoding = None <EOL> driver = '<STR_LIT>' <EOL> def __init__ ( self , ** kwargs ) : <EOL> SQLiteDialect . __init__ ( self , ** kwargs ) <EOL> if self . dbapi is not None : <EOL> sqlite_ver = self . dbapi . version_info <EOL> if sqlite_ver < ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> ) : <EOL> util . warn ( <EOL> ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) % <EOL> '<STR_LIT:.>' . join ( [ str ( subver ) for subver in sqlite_ver ] ) ) <EOL> @ classmethod <EOL> def dbapi ( cls ) : <EOL> try : <EOL> from pysqlite2 import dbapi2 as sqlite <EOL> except ImportError as e : <EOL> try : <EOL> from sqlite3 import dbapi2 as sqlite <EOL> except ImportError : <EOL> raise e <EOL> return sqlite <EOL> @ classmethod <EOL> def get_pool_class ( cls , url ) : <EOL> if url . database and url . database != '<STR_LIT>' : <EOL> return pool . NullPool <EOL> else : <EOL> return pool . SingletonThreadPool <EOL> def _get_server_version_info ( self , connection ) : <EOL> return self . dbapi . sqlite_version_info <EOL> def create_connect_args ( self , url ) : <EOL> if url . username or url . password or url . host or url . port : <EOL> raise exc . ArgumentError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( url , ) ) <EOL> filename = url . database or '<STR_LIT>' <EOL> if filename != '<STR_LIT>' : <EOL> filename = os . path . abspath ( filename ) <EOL> opts = url . query . copy ( ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , float ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , str ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , int ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , bool ) <EOL> util . coerce_kw_type ( opts , '<STR_LIT>' , int ) <EOL> return ( [ filename ] , opts ) <EOL> def is_disconnect ( self , e , connection , cursor ) : <EOL> return isinstance ( e , self . dbapi . ProgrammingError ) and "<STR_LIT>" in str ( e ) <EOL> dialect = SQLiteDialect_pysqlite </s>
