mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 19:31:54 +08:00
_mysql: Move type converter initialization outside of module. When opening
the connection, a mapping of MySQL types to Python functions may be passed as the keyword argument conv. This is stored as the converter attribute on the connection object, and may be modified, assigned, etc. MySQLdb: Build full converter dictionary, pass along to _mysql when creating a connection. MySQL_doc: Fixed a minor documentation bug.
This commit is contained in:
@ -24,6 +24,15 @@ threadsafety = 1
|
||||
apilevel = "2.0"
|
||||
paramstyle = "format"
|
||||
|
||||
type_conv = { FIELD_TYPE.TINY: int,
|
||||
FIELD_TYPE.SHORT: int,
|
||||
FIELD_TYPE.LONG: int,
|
||||
FIELD_TYPE.FLOAT: float,
|
||||
FIELD_TYPE.DOUBLE: float,
|
||||
FIELD_TYPE.LONGLONG: long,
|
||||
FIELD_TYPE.INT24: int,
|
||||
FIELD_TYPE.YEAR: int }
|
||||
|
||||
try:
|
||||
from DateTime import Date, Time, Timestamp, ISO
|
||||
|
||||
@ -242,6 +251,7 @@ class Connection:
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
from _mysql import connect
|
||||
if not kwargs.has_key('conv'): kwargs['conv'] = type_conv
|
||||
self.db = apply(connect, (), kwargs)
|
||||
|
||||
def close(self):
|
||||
|
Reference in New Issue
Block a user