_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:
adustman
1999-07-15 22:14:42 +00:00
parent 2353d9ff30
commit c3d23b6858
3 changed files with 71 additions and 60 deletions

View File

@ -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):