On Sun, 2013-02-10 at 10:59:30 -0800, junepeach wrote: > Thanks very much for the explanation about the difference between view > and temporary table. But now, I am thinking about how to realize it in > sqlalchemy and use it in as many databases as possible.
If you're talking about temporary tables, then this will do:
class Test(Base):
__tablename__ = 'test_table'
__table_args__ = {'prefixes': ['TEMPORARY']}
# ...
Haven't tested this thoroughly, you may need to bind session to a single
connection instead of engine and use that same connection to create the
table, as at least in PostgreSQL temporary tables exist only for a
connection they were created in. Not sure how they work in other RDBMS.
If you meant the views, then map and query them as ordinary tables.
--
Audrius Kažukauskas
http://neutrino.lt/
pgpNQdc7Wuvvk.pgp
Description: PGP signature
