def db_schema(db, table):
typedict = [('<STR_LIT:int>', int), ('<STR_LIT>', float),<EOL>('<STR_LIT>', datetime),<EOL>('<STR_LIT:date>', date), ('<STR_LIT:time>', dttime),<EOL>('<STR_LIT:text>', str), ('<STR_LIT>', str)]<EOL>ret = {}<EOL>q = '''<STR_LIT>'''<EOL>for row in query(db, q, (table,)):<EOL><INDENT>name, dtype = tuple( row[:<NUM_LIT:2>] )<EOL>name = str(name)<EOL>for tn, tt in typedict:<EOL><INDENT>if tn in dtype:<EOL><INDENT>ret[name] = tt<EOL>break<EOL><DEDENT><DEDENT>if name not in ret:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise RuntimeError(msg % (name, dtype))<EOL><DEDENT><DEDENT>return ret<EOL>
only works for postgres

@return dictionary of column name -> data type