Thx Simon,
I tried Base.metadata.create_all(engine, checkfirst=False)
but it throws an error.
When checkfirst is True, the declaration works.
I don t understand...
Maybe orm needs additional information in declarative classes when checkfirst=False because orm doesn t look in database in this case?
These is the error :
Z:\>python Declaration.py
Le temps de chargement des modules SQL ALCHEMY 0.25
Le temps de dÚclaration SQL ALCHEMY 0.156000137329
Traceback (most recent call last):
File "Declaration.py", line 1435, in <module>
Base.metadata.create_all(engine, checkfirst=False)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sche
ma.py", line 1796, in create_all
bind.create(self, checkfirst=checkfirst, tables=tables)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 1129, in create
self._run_visitor(self.dialect.schemagenerator, entity, connection=connectio
n, **kwargs)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 1158, in _run_visitor
visitorcallable(self.dialect, conn, **kwargs).traverse(element)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sql\
visitors.py", line 89, in traverse
return traverse(obj, self.__traverse_options__, self._visitor_dict)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sql\
visitors.py", line 200, in traverse
return traverse_using(iterate(obj, opts), obj, visitors)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sql\
visitors.py", line 194, in traverse_using
meth(target)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sql\
compiler.py", line 831, in visit_metadata
self.traverse_single(table)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sql\
visitors.py", line 79, in traverse_single
return meth(obj)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\sql\
compiler.py", line 870, in visit_table
self.execute()
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 1812, in execute
return self.connection.execute(self.buffer.getvalue())
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 824, in execute
return Connection.executors[c](self, object, multiparams, params)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 888, in _execute_text
return self.__execute_context(context)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 896, in __execute_context
self._cursor_execute(context.cursor, context.statement, context.parameters[0
], context=context)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 950, in _cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor, context)
File "c:\python25\lib\site-packages\SQLAlchemy-0.5.6-py2.5.egg\sqlalchemy\engi
ne\base.py", line 931, in _handle_dbapi_exception
raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidat
ed=is_disconnect)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) (1064, "Erreur de syntaxe pr
\xe8s de ' \n\tcp VARCHAR, \n\tlatitude VARCHAR, \n\tlongitude VARCHAR, \n\teloi
gn' \xe0 la ligne 3") '\nCREATE TABLE maps_ville (\n\t`IdVille` INTEGER NOT NULL
AUTO_INCREMENT, \n\tnom VARCHAR, \n\tcp VARCHAR, \n\tlatitude VARCHAR, \n\tlong
itude VARCHAR, \n\teloignement VARCHAR, \n\turl VARCHAR, \n\tPRIMARY KEY (`IdVil
le`)\n)\n\n' ()