Keji Li

SQLAlchemy, Random tips

Some obscure points to note when using sqlalchemy:

  1. if you want to use numpy or your engine is sqlite, use Float columns instead of Numeric columns
  2. you can change your database defining script and have it run as long as the changes don't affect the tables, i.e.: change column type between numeric and float, add relationships on existing foreign keys.
  3. sqlalchemy doesn't auto generate __init__. The default one doesn't take any args. The an easy way to write init is to have a fields tuple and iter through *varargs and **kwargs
  4. when using hierarchy on single tables, don't force NOT NULL on children's fields