Alexis B
unread,May 6, 2008, 10:06:08 AM5/6/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sqlalchemy
Hi to all,
This may be a newbie question but I just can't find the answer. I have
to make multiple submissions to a postgresql table and I want to use
python. I found everything to execute my insert commands, the problem
is that I have to repeat it regularly, and I expected not to check
which record have already inserted thanks to the primary key ( which
is a couple if integer I set ).
So when it tries to insert again some records, it doesn't insert it,
as expected, but it raises an error which interrupt the script :
**************************************************
Traceback (most recent call last):
File "./script.py", line 44, in <module>
connection.execute(line)
File " . . ./python-2.5.1/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/engine/base.py", line 844, in
execute
return Connection.executors[c](self, object, multiparams, params)
File ". . ./python-2.5.1/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/engine/base.py", line 854, in
_execute_text
self.__execute_raw(context)
File ". . ./python-2.5.1/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/engine/base.py", line 916, in
__execute_raw
self._cursor_execute(context.cursor, context.statement,
context.parameters[0], context=context)
File ". . ./python-2.5.1/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/engine/base.py", line 960, in
_cursor_execute
self._handle_dbapi_exception(e, statement, parameters, cursor)
File ". . ./python-2.5.1/lib/python2.5/site-packages/
SQLAlchemy-0.4.5-py2.5.egg/sqlalchemy/engine/base.py", line 942, in
_handle_dbapi_exception
raise exceptions.DBAPIError.instance(statement, parameters, e,
connection_invalidated=is_disconnect)
sqlalchemy.exceptions.IntegrityError: (IntegrityError) duplicate key
violates unique constraint "my_primarykey"
"INSERT INTO . . . )" {}
**************************************************
So I just wanted to know if there was an option to ignore the error ,
which possibly raise it, but don't interrupt the script.
Thanks