import sqlalchemy.sql as sql
import StringIO
+class TypeDescriptor(object):
+ def get_col_spec(self):
+ raise NotImplementedError()
+ def convert_bind_param(self, value):
+ raise NotImplementedError()
+ def convert_result_value(self, value):
+ raise NotImplementedError()
+
class SchemaIterator(schema.SchemaVisitor):
"""a visitor that can gather text into a buffer and execute the contents of the buffer."""
self.tables = {}
self.notes = {}
+ def type_descriptor(self, type):
+ raise NotImplementedError()
+
def schemagenerator(self, proxy, **params):
raise NotImplementedError()
c = connection.cursor()
self.pre_exec(connection, c, statement, parameters, echo = echo, **kwargs)
+ # TODO: affix TypeDescriptors ehre to pre-process bind params
if isinstance(parameters, list):
c.executemany(statement, parameters)
else:
class ResultProxy:
- def __init__(self, cursor, echo = False):
+ def __init__(self, cursor, echo = False, engine = None):
self.cursor = cursor
self.echo = echo
+ self.engine = engine
metadata = cursor.description
self.props = {}
i = 0
+ # TODO: affix TypeDescriptors here to post-process results
if metadata is not None:
for item in metadata:
self.props[item[0]] = i
# TODO: get some notion of "primary mapper" going so multiple mappers dont collide
self.class_._mapper = self.hashkey
- def instances(self, cursor, db = None):
+ def instances(self, cursor, db):
result = util.HistoryArraySet()
- cursor = engine.ResultProxy(cursor, echo = db and db.echo, engine = db)
+ cursor = engine.ResultProxy(cursor, db, echo = db.echo)
imap = {}
while True:
row = cursor.fetchone()
__ALL__ = ['Table', 'Column', 'Sequence', 'ForeignKey',
'INT', 'CHAR', 'VARCHAR', 'TEXT', 'FLOAT', 'DECIMAL',
- 'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN'
+ 'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN', 'String', 'Integer', 'Numeric', 'DateTime', 'Binary',
]
-class INT:
- """integer datatype"""
- pass
-
-INTEGER = INT
-class CHAR:
- """character datatype"""
+class String:
def __init__(self, length):
self.length = length
-class VARCHAR:
- def __init__(self, length):
- self.length = length
+class Integer:
+ """integer datatype"""
+ pass
class Numeric:
def __init__(self, precision, length):
self.precision = precision
self.length = length
+
+class DateTime:
+ pass
+
+class Binary:pass
+class Boolean:pass
+
class FLOAT(Numeric):pass
-class TEXT: pass
+class TEXT(String): pass
class DECIMAL(Numeric):pass
-class TIMESTAMP: pass
-class DATETIME: pass
-class CLOB: pass
-class BLOB: pass
-class BOOLEAN: pass
+class INT(Integer):pass
+INTEGER = INT
+class TIMESTAMP(DateTime): pass
+class DATETIME(DateTime): pass
+class CLOB(String): pass
+class VARCHAR(String): pass
+class CHAR(String):pass
+class BLOB(Binary): pass
+class BOOLEAN(Boolean): pass
class SchemaItem(object):
c = s.compile()
print "\n" + str(c) + repr(c.get_params())
- l = m.instances(s.execute(emailad = 'jack@bean.com'))
+ l = m.instances(s.execute(emailad = 'jack@bean.com'), users.engine)
print repr(l)
def testmulti(self):