Hey,

I'm having an issue with SQLObject 0.10.2 on Mac OS X 10.5 with Python
2.5. Basically, I am running unit tests and in the setUp() method I
create some tables. In the tearDown() method I just os.path.unlink()
the database (Its an sqlite db). The problem arrises on the second run
of setUp(). I get the following stack trace:

Traceback (most recent call last):
  File "/Users/sean/Documents/workspace/mars/src/database/testEntities.py",
line 23, in setUp
    CommitLog.createTable()
  File 
"/Library/Python/2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/main.py",
line 1395, in createTable
    constraints = conn.createTable(cls)
  File 
"/Library/Python/2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/dbconnection.py",
line 433, in createTable
    self.query(createSql)
  File 
"/Library/Python/2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/dbconnection.py",
line 337, in query
    return self._runWithConnection(self._query, s)
  File 
"/Library/Python/2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/dbconnection.py",
line 250, in _runWithConnection
    val = meth(conn, *args)
  File 
"/Library/Python/2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/dbconnection.py",
line 334, in _query
    self._executeRetry(conn, conn.cursor(), s)
  File 
"/Library/Python/2.5/site-packages/SQLObject-0.10.2-py2.5.egg/sqlobject/sqlite/sqliteconnection.py",
line 177, in _executeRetry
    raise OperationalError(ErrorMessage(e))
OperationalError: table commit_log already exists

It looks like SQLObject is doing some funky caching on the connection
because the database doesn't even exist anymore. The following is the
setUp and tearDown methods:

    def setUp(self):
        self.dbName = 'testDb'
        self.conn = Connection(self.dbName)
        self.conn.connect()

        CommitLog.createTable()

    def tearDown(self):
        if os.path.exists(self.dbName):
            os.unlink(self.dbName)

The Connection class is something I created to just wrap around the
SQLObject connection creation and its connect method contains the
following code:

        connString = ''.join(['sqlite:', self.dbPath])
        connection = connectionForURI(connString)
        sqlhub.processConnection = connection

This thread from a few years ago seems to be the same problem but
there isn't any resolution that I can see,
http://osdir.com/ml/python.sqlobject/2003-03/msg00008.html

>From reading the mailing list etc. I thought something like
'sqlhub.getConnection().expireAll()' would help but apparently not.
I've also tried setting the 'cache' variable on the connection object
to False to no avail. If anyone could explain what is going on here I
would appreciate it.

Cheers,
nnp

-- 
http://www.smashthestack.org
http://www.unprotectedhex.com

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to