python - Check table compatibility in sqlalchemy -


i have tables declared represent remote databases.

i want check table definitions match remote databases connect to.

i have following function:

def verify_db_tables(conn, metadata):     """checks tables declared in metadata in db"""     table in metadata.tables.values():         check = sqlalchemy.metadata()         check.reflect(conn, table.schema, true, (table.name,))         check = check.tables[table.key]         column in table.c:             if column.name not in check.c:                 raise exception("table %s not contain column %s" %                         (table.key, column.name))             check_column = check.c[column.name]             if check_column.type != column.type:                 raise exception("column %s.%s %s expected %s" %                         (table.key, column.name, check_column.type, column.type)) 

i don't care if there additional columns in tables, , don't care if there additional tables.

however, when run code, following error:

exception: column dx.mail_data.message_id integer expected integer 

how check column in reflected table of same type definition?

sqlite uses class heiarchy work nicely

    if not instance(check_column.type, column.type.__class__): 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -