On 28/09/2011 13:19, Michael Bayer wrote:
well the easiest is mytable.drop(engine, checkfirst=True).
The "check" is not within the DropTable construct, which represents just the
actual DROP TABLE statement. If you were using DropTable directly you'd call
engine.has_table(tablename) first to check for it.
Hmm, but both mysql and postgres (I suspect others do too, but I haven't
checked) have "DROP TABLE IF EXISTS" statements so you don't need to do
any checking. That feels like it should be supported by the DropTable
construct, what am I missing?
Anyway, in an effort to get this, I tried:
File "...model.py",
line 46, in <module>
engine.execute('drop table if exists %s', table.name)
File "sqlalchemy/engine/base.py",
line 2285, in execute
return connection.execute(statement, *multiparams, **params)
File "sqlalchemy/engine/base.py",
line 1399, in execute
params)
File "sqlalchemy/engine/base.py",
line 1576, in _execute_text
statement, parameters
File "sqlalchemy/engine/base.py",
line 1640, in _execute_context
context)
File "sqlalchemy/engine/base.py",
line 1633, in _execute_context
context)
File "sqlalchemy/engine/default.py",
line 325, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at or
near "E'table_name'"
LINE 1: drop table if exists E'table_name'
Where's that E coming from?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.