def get_pool(provider, *args, **kwargs): if 'conv' not in kwargs: conv = mysql_converters.conversions.copy() if mysql_module_name == 'MySQLdb': conv[FIELD_TYPE.BLOB] = [(FLAG.BINARY, buffer)] conv[timedelta] = lambda td, c: string_literal(timedelta2str(td), c) conv[FIELD_TYPE.TIMESTAMP] = str2datetime conv[FIELD_TYPE.DATETIME] = str2datetime conv[FIELD_TYPE.TIME] = str2timedelta kwargs['conv'] = conv if 'charset' not in kwargs: kwargs['charset'] = 'utf8' kwargs['client_flag'] = kwargs.get('client_flag', 0) | CLIENT.FOUND_ROWS return Pool(mysql_module, *args, **kwargs)
def encode_timedelta(val, encoders=None): return string_literal(timedelta2str(val), encoders)
def encode_buffer(val, encoders=None): return string_literal(str(val), encoders)
def literal(value=None): if not value: return 'NULL' return string_literal(value)
def safe_string(x): #if "'" in x: x = escape_string(x) return string_literal(x)
def DateTimeDelta2literal(d, c): """Format a DateTimeDelta object as a time.""" return string_literal(format_TIMEDELTA(d),c)
def DateTime2literal(d, c): """Format a DateTime object as an ISO timestamp.""" return string_literal(format_TIMESTAMP(d),c)