In python, I populate the SQLITE database with importmany, so I can import tens of thousands of rows of data right away. My data is contained in a list of tuples. I had a database configured with primary keys where I wanted them.
The problem I ran into was that primary key errors caused IntegrityError. If I handle the exception, my script stops importing in the primary key conflict.
try:
try: self.curs.executemany("INSERT into towers values (NULL,?,?,?,?)",self.insertList) except IntegrityError: print "Primary key error" conn.commit()
So my questions are: in python using importmany I can:
1. Capturing values ββthat violate the primary key?
2. Continue to download data after receiving my primary errors.
I understand why it does not continue to load, because after the exception, I commit the data in the database. I do not know how to continue where I left off. Unforutnley I can not copy and paste all the code on this network, any help would be greatly appreciated. Right now I donβt have PCs that work like work ...
python sql sqlite sqlite3
dan
source share