On Dec 15, 2005, at 7:41 PM, limodou wrote:
I think if I can test the table exist as:
if not table.name in sqlite_engine.tables:
table.create()
This code is ok?
well that doesnt do any kind of SQL to actually ask the database for
a table.
I think what would happen now if a table doesnt exist, is that youd
get a Table with no columns, since for the 3 engines that do
reflection right now its querying a view that returns zero or more rows.
so maybe you could do:
t = Table('mytable', engine, autoload=True)
exists = len(t.columns) > 0
if you are really writing code where you want to create the table if
it doesnt exist, i guess you could do the above, then if it doesnt
exist, say:
t = Table('mytable', engine,
Column('col1' ...),
Column('col2', ...),
...
redefine=True
)
t.create()
"redefine" means to take the table thats currently in the 'tables'
dictionary and replace its columns with the new ones.
I guess what we are really looking for here is a method called
create_if_needed(), right ?
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users