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' ()
2009/10/1 King Simon-NFHD78 <[email protected]>
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Christian Démolis
> > Sent: 01 October 2009 10:40
> > To: [email protected]
> > Subject: [sqlalchemy] Bypass checking to database structure
> > (metadata.create_all)
> >
> > Hi again,
> >
> > Is there any way to avoid checking database structure during
> > the metadata.create_all declaration's phase?
> > It can be good to check when we are in test phase but when we
> > are in production and we are sure of our model, it can be
> > good to bypass create_all checking to database.
> >
>
> create_all (and drop_all) have a 'checkfirst' parameter that defaults to
> True. If you set it to False, SA won't check to see if your tables already
> exist before issuing the CREATE statements:
>
> <
> http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/schema.html#sqlalchemy.schema.MetaData.create_all
> >
>
> Hope that helps,
>
> Simon
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---