Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread abhinav raj kp nirmallur
Sir I don't know nothing about programming but I have a great intrest in it so that now a days I began to study python, many of my friends and teachers suggest me it. But still I have no tutor, can you please suggest me to study python using book or any good websit. Thanks. Abhinav Raj >From Cal

Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread eryksun
On Sun, Feb 9, 2014 at 5:20 AM, Peter Otten <__pete...@web.de> wrote: > > The idea here is to wrap the iterable of records to be inserted in the Iter > class which keeps track of the last accessed row. You could also use a parameters iterator, e.g. `it = iter(to_db)`. Then for an IntegrityError, l

Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread Sivaram Neelakantan
On Sun, Feb 09 2014,Peter Otten wrote: > Sivaram Neelakantan wrote: > [snipped 32 lines] > > If nobody here comes up with a good way to find the offending record you > could ask in a mailing list/newsgroup dedicated to sqlite (Please report > back here if you do). If there is no "official" way

Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread Sivaram Neelakantan
On Sun, Feb 09 2014,Steven D'Aprano wrote: > On Sun, Feb 09, 2014 at 12:03:43PM +0530, Sivaram Neelakantan wrote: > [snipped 8 lines] > When you get an error, and don't know how to interpret it, the first > thing to do is to look at the exception and see what it says. > > try: > # as above

Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread Peter Otten
Sivaram Neelakantan wrote: > > I've written this code that seems to work and I'd like to know how to get > the record that causes the abort. Apparently 'executemany' doesn't > support lastrow? And if it doesn't, any suggestions? > > --8<---cut here---start->

Re: [Tutor] catching the row that raises IntegrityError in sqlite

2014-02-09 Thread Steven D'Aprano
On Sun, Feb 09, 2014 at 12:03:43PM +0530, Sivaram Neelakantan wrote: > try: > sql = "insert into %s (%s) values(%s)" %(name, cl, cvv) > conn.executemany(sql, to_db) > dbh.commit() > except sq.IntegrityError: > print('Record already exists') # but which recor

[Tutor] catching the row that raises IntegrityError in sqlite

2014-02-08 Thread Sivaram Neelakantan
I've written this code that seems to work and I'd like to know how to get the record that causes the abort. Apparently 'executemany' doesn't support lastrow? And if it doesn't, any suggestions? --8<---cut here---start->8--- def table_load(datafile,name,conn,d