Quoting Oleg Broytmann <[EMAIL PROTECTED]>:
On Thu, Mar 16, 2006 at 08:59:43PM -0600, [EMAIL PROTECTED] wrote:
But the original connection stays "open" (is that the correct word) until I
terminate the instance of Python I'm running.
Does connection.close() help?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
Hi Oleg,
This works to some degree but the original file still isn't completely free'd.
(I'm using SQLite)
The case that fails is:
* User creates a new database
* User closes database
* User creates a new database with the same name as the old database (I check
for file exists and delete it before creating a new database)
SQLObject(SQLite?) returns that the database isn't open????
Example code:
---------------------------------------------------------------
from sqlobject import *
import os
filename='c:/test123.db'
# table to test with
class Test(SQLObject):
desc=StringCol()
# delete filename if it exists
if os.path.exists(filename):
os.unlink(filename)
# setup and create connection
connection_string='sqlite:/' + filename.replace(':', '|')
connection = connectionForURI(connection_string)
sqlhub.processConnection = connection
# create table / add record get record
Test.createTable()
Test(desc='testing 1 2 3')
print Test.get(1)
# close connection
connection.close()
sqlhub.processConnection = connection # is this required?
# delete file
os.unlink(filename)
# do it all again
connection_string='sqlite:/' + filename.replace(':', '|')
connection = connectionForURI(connection_string)
sqlhub.processConnection = connection
Test.createTable() # crashes here
Test(desc='testing 1 2 3')
print Test.get(1)
connection.close()
sqlhub.processConnection = connection
---------------------------------------------------------------
Traceback:
---------------------------------------------------------------
<Test 1 desc='testing 1 2 3'>
Traceback (most recent call last):
File "db_test.py", line 35, in ?
Test.createTable() # crashes here
File
"d:\dev\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\main.py",
line 1308, in createTable
conn.createTable(cls)
File
"d:\dev\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 516, in createTable
self.query(self.createTableSQL(soClass))
File
"d:\dev\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 303, in query
return self._runWithConnection(self._query, s)
File
"d:\dev\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 219, in _runWithConnection
self.releaseConnection(conn)
File
"d:\dev\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py",
line 261, in releaseConnection
conn.commit()
pysqlite2.dbapi2.ProgrammingError: Cannot operate on a closed database.
Execution finished.
---------------------------------------------------------------
Any help is very much appreciated.
Thanks,
Ray Smith
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss