When I specify a timeout for a sqlite connection that uses the older 
sqlite db module I get the following warning:

/usr/lib/python2.3/site-packages/sqlite/main.py:472: DeprecationWarning: 
integer argument expected, got float
  self.db.sqlite_busy_timeout(timeout)

This is because the older sqlite module expects the timeout as an integer 
representing the number of milliseconds, while the newer pysqlite2 wants 
a float with the number of seconds.

The attached patch fixes the issue and also unifies how the timeout is 
specified for sqlite connections. The timeout parameters in sqlobject 
will always be in seconds and internally will be sent as the integer 
number of milliseconds if the sqlite backend is the old one.

-- 
Dan
--- sqlobject.orig/sqlite/sqliteconnection.py	2005-10-02 01:59:33.000000000 +0300
+++ sqlobject/sqlite/sqliteconnection.py	2006-05-31 14:59:55.000000000 +0300
@@ -41,7 +41,10 @@
             if 'mode' in kw:
                 opts['mode'] = int(popKey(kw, 'mode'), 0)
         if 'timeout' in kw:
-            opts['timeout'] = float(popKey(kw, 'timeout'))
+            if using_sqlite2:
+                opts['timeout'] = float(popKey(kw, 'timeout'))
+            else:
+                opts['timeout'] = int(float(popKey(kw, 'timeout')) * 1000)
         # use only one connection for sqlite - supports multiple)
         # cursors per connection
         self._conn = sqlite.connect(self.filename, **opts)

Reply via email to