Unfortunately, I don't know any database that enforces integrity constraints and will do what you want to do. Standard DB designs say "Make a transaction, insert data, and roll back if an error occurs". Short of doing a commit after every write or preventing any attempt to write data that violates those integrity constraints, I don't have an option for you. I'm sorry.
On Mon, Jan 31, 2011 at 7:35 PM, Lukasz Szybalski <[email protected]> wrote: > Hello, > I've inserted record into database, then record got changed in the database. > > Now I have more record to insert, some that I've already imported and > will give me "Unique key error" aka IntegrityError. In sql I was able > to tell to dissregard these errors and continue to next record. > > In TG2 I have created a load.py file that has: > > from ubs.model import * > > conf_dict = appconfig('config:%s' % os.path.join(os.getcwd(), > '../../development.ini')) > engine = create_engine(conf_dict['sqlalchemy.url']) > engine.echo=False > init_model(engine) > #end of tg2 session > > from ubs.model import DBSession, metadata > from ubs.model.policy import Policy, Installment > import transaction > > #some manipulation > > > transaction.commit > > But the transaction Will not allow me to skip the "duplicate key" ? > How can I do that? > > One option is to change from autocommit = False to True and catch the > exceptions but then I would need to redo the whole sessionmake from > tg2 model/__init__.py ???? > > Is there a way I can tell transaction.commit to "warn me about the > integrity errors, but allow the rest of the transactions that are good > to go through and commit?" > > Thanks, > Lucas > > > > try excpt Integrity error by doing DBSession.flush does not work: > sqlalchemy.exc.InvalidRequestError: This Session's transaction has > been rolled back due to a previous exception during flush. To begin a > new transaction with this Session, first issue Session.rollback(). > Original exception was: (IntegrityError) columns........... > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" 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/turbogears?hl=en. > > -- Michael J. Pedersen My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171 Yahoo/pedermj2002, MSN/[email protected] -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

