Grimsqueaker wrote: > I am trying to reflect a table from a database and use > table.tometadata() to copy it into an identical database. This usually > works, but when I try to call table.create() on a certain new table, I > get a ProgrammingError. I can see that this may be due the fact that > the server_default on one of the columns has been double quoted. Can > anyone point me in the right direction to reflect / create this table > properly?
it sounds like a bug we fixed in 0.6 so you might want to try 0.6. > > Below is the traceback I got. Note the quotes around the > server_default for the "date" column - it has two single quotes, not > double quotes. The tables that worked did not have this. > > > 2010-03-08 12:44:45,205 INFO sqlalchemy.engine.threadlocal.TLEngine. > 0x...0b50 DESCRIBE `radpostauth` > INFO:sqlalchemy.engine.threadlocal.TLEngine.0x...0b50:DESCRIBE > `radpostauth` > 2010-03-08 12:44:45,205 INFO sqlalchemy.engine.threadlocal.TLEngine. > 0x...0b50 () > INFO:sqlalchemy.engine.threadlocal.TLEngine.0x...0b50:() > 2010-03-08 12:44:45,217 INFO sqlalchemy.engine.threadlocal.TLEngine. > 0x...0b50 ROLLBACK > INFO:sqlalchemy.engine.threadlocal.TLEngine.0x...0b50:ROLLBACK > 2010-03-08 12:44:45,220 INFO sqlalchemy.engine.threadlocal.TLEngine. > 0x...0b50 > CREATE TABLE radpostauth ( > id INTEGER(11) NOT NULL AUTO_INCREMENT, > user VARCHAR(64) DEFAULT '' NOT NULL, > pass VARCHAR(64) DEFAULT '' NOT NULL, > reply VARCHAR(32) DEFAULT '' NOT NULL, > date TIMESTAMP DEFAULT ''0000-00-00 00:00:00'' NOT NULL, > PRIMARY KEY (id) > ) > > > INFO:sqlalchemy.engine.threadlocal.TLEngine.0x...0b50: > CREATE TABLE radpostauth ( > id INTEGER(11) NOT NULL AUTO_INCREMENT, > user VARCHAR(64) DEFAULT '' NOT NULL, > pass VARCHAR(64) DEFAULT '' NOT NULL, > reply VARCHAR(32) DEFAULT '' NOT NULL, > date TIMESTAMP DEFAULT ''0000-00-00 00:00:00'' NOT NULL, > PRIMARY KEY (id) > ) > > > 2010-03-08 12:44:45,220 INFO sqlalchemy.engine.threadlocal.TLEngine. > 0x...0b50 () > INFO:sqlalchemy.engine.threadlocal.TLEngine.0x...0b50:() > 2010-03-08 12:44:45,221 INFO sqlalchemy.engine.threadlocal.TLEngine. > 0x...0b50 ROLLBACK > INFO:sqlalchemy.engine.threadlocal.TLEngine.0x...0b50:ROLLBACK > 2010-03-08 12:44:45,221 INFO sqlalchemy.pool.QueuePool.0x...0a50 > Connection <_mysql.connection open to 'localhost' at 202c050> being > returned to pool > INFO:sqlalchemy.pool.QueuePool.0x...0a50:Connection <_mysql.connection > open to 'localhost' at 202c050> being returned to pool > Traceback (most recent call last): > File "db.py", line 142, in <module> > copy_schema() > File "db.py", line 106, in copy_schema > dsttable.create(checkfirst=True) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/schema.py", line 381, in create > self.metadata.create_all(bind=bind, checkfirst=checkfirst, > tables=[self]) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/schema.py", line 1796, in create_all > bind.create(self, checkfirst=checkfirst, tables=tables) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 1129, in create > self._run_visitor(self.dialect.schemagenerator, entity, > connection=connection, **kwargs) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 1158, in _run_visitor > visitorcallable(self.dialect, conn, **kwargs).traverse(element) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/sql/visitors.py", line 89, in traverse > return traverse(obj, self.__traverse_options__, > self._visitor_dict) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/sql/visitors.py", line 200, in traverse > return traverse_using(iterate(obj, opts), obj, visitors) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/sql/visitors.py", line 194, in traverse_using > meth(target) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/sql/compiler.py", line 831, in visit_metadata > self.traverse_single(table) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/sql/visitors.py", line 79, in traverse_single > return meth(obj) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/sql/compiler.py", line 870, in visit_table > self.execute() > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 1812, in execute > return self.connection.execute(self.buffer.getvalue()) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 824, in execute > return Connection.executors[c](self, object, multiparams, params) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 888, in _execute_text > return self.__execute_context(context) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 896, in __execute_context > self._cursor_execute(context.cursor, context.statement, > context.parameters[0], context=context) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 950, in _cursor_execute > self._handle_dbapi_exception(e, statement, parameters, cursor, > context) > File "/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.5.6- > py2.6.egg/sqlalchemy/engine/base.py", line 931, in > _handle_dbapi_exception > raise exc.DBAPIError.instance(statement, parameters, e, > connection_invalidated=is_disconnect) > sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1064, "You have > an error in your SQL syntax; check the manual that corresponds to your > MySQL server version for the right syntax to use near '0000-00-00 > 00:00:00'' NOT NULL, \n\tPRIMARY KEY (id)\n)' at line 6") u"\nCREATE > TABLE radpostauth (\n\tid INTEGER(11) NOT NULL AUTO_INCREMENT, \n > \tuser VARCHAR(64) DEFAULT '' NOT NULL, \n\tpass VARCHAR(64) DEFAULT > '' NOT NULL, \n\treply VARCHAR(32) DEFAULT '' NOT NULL, \n\tdate > TIMESTAMP DEFAULT ''0000-00-00 00:00:00'' NOT NULL, \n\tPRIMARY KEY > (id)\n)\n\n" () > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@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. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@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.