I'm completely stumped on an intermittent error I am getting in sqlite3. The problem is that the exact same script will occasionally run to completion, or it will fail on a seemingly random SELECT statement. Since it's not properly repeatable, I don't know if it's me doing something wrong or if there's a bug. I've seen a very similar issue on this mailing list but Guido van Rossum just referred them elsewhere and I can't find the follow-up.
The boiled-down code:
import sqlite3
conn = sqlite3.connect('c2c_orders.db')
c = conn.cursor()
tracking_nos = [u'1615146623203', u'1614117623187', u'1614174623176',
u'1614141623103', u'1614141623101', u'1613102623033',
u'1612192622864', u'1612104622842', u'1612109622787',
u'1612137622586', u'1612137622583', u'1611191622448',
u'1611166622426', u'1610118621895']
for num in tracking_nos:
print num
c.execute("SELECT * FROM mw_orders WHERE id=(?)", (num,))
conn.commit()
db_result = c.fetchall()
I can run this once and from the print statement I will get:
1615146623203
1614117623187
1614174623176
1614141623103
1614141623101
1613102623033
...
Fine. The tracking numbers don't exist in the table so it is returning an empty list. Reset everything and run again:
1615146623203
1614117623187
---------------------------------------------------------------------------
InterfaceError Traceback (most recent call last)
C:\...path... in <module>()
113
114 orders = check_orders()
--> 115 orderInfo = get_detailed_info(orders)
116
117 end = datetime.datetime.now()
C:\C:\...path... in get_detailed_info(tracking_no)
63 data_list = get_data.json()
64
---> 65 c.execute("SELECT * FROM mw_orders WHERE id=(?)", (num,))
66 conn.commit()
67 db_result = c.fetchall()
InterfaceError: Error binding parameter 0 - probably unsupported type.
Errors relate to the main script so lines don't match up. But I don't understand. This can happen on any number or none at all. As far as I can tell I set my query up correctly.
This is with sqlite3 version 2.6.0 running on Python 2.7 in Enthought Canopy. Has anyone seen this before and know how to get around this? Thanks in advance.
EDIT The db lock mentioned in my comments persists over a Windows reboot. Using the software described here here I get the following, showing that the last modified date is before the reboot
The sequence of events is even stranger. The errors currently alternate as follows. First attempt to read database will print the following to console (prints tracking number and type immediately prior to the query that throws the error)
%run "C:\Users\Joshua\Canopy\PCscripts\full_vehicle_routing\dbSyncer2.py"
1608123637974
<type 'unicode'>
1608188637849
<type 'unicode'>
1607105637842
<type 'unicode'>
1607133637841
<type 'unicode'>
---------------------------------------------------------------------------
InterfaceError Traceback (most recent call last)
C:\Users\Joshua\Canopy\PCscripts\full_vehicle_routing\dbSyncer2.py in <module>()
312 removeChecks = remove_all_checks()
313 orders = check_orders()
--> 314 orderInfo = get_detailed_info(orders)
315 checkOldOrders = check_old_orders()
316
C:\Users\Joshua\Canopy\PCscripts\full_vehicle_routing\dbSyncer2.py in get_detailed_info(tracking_no)
90 data_list = get_data.json()
91
---> 92 c.execute("SELECT * FROM mw_orders WHERE id=(?)", (num,))
93 conn.commit()
94 db_result = c.fetchall()
InterfaceError: Error binding parameter 0 - probably unsupported type.
Try running it again and get:
C:\Users\Joshua\Canopy\PCscripts\full_vehicle_routing\dbSyncer2.py in remove_all_checks()
65
66 def remove_all_checks():
---> 67 c.execute("UPDATE mw_orders SET is_checked = '0'")
68 conn.commit()
69
OperationalError: database is locked
Then running the same script again gives the first error. It either ping-pongs between the two or creates a persistent lock (which I assume is a fully-corrupted db. No other process uses this script, I'm developing it as a test in Canopy and only this script uses the db