Hi guys,

I'd like to use an in-memory sqlite database for testing, and I have a problem where I don't seem to be able to let go of a database which was once created. Here's a test that shows what I mean:

class Foo(sqlobject.SQLObject):
  bar = sqlobject.UnicodeCol(length=250, unique=True)

db_uri = 'sqlite:/:memory:'
conn = sqlobject.connectionForURI(db_uri)
sqlobject.sqlhub.processConnection = conn
Foo.createTable()
# All is good so far. Now let's drop the database.
conn.close()
del conn
# From http://www.sqlite.org/inmemorydb.html:
# "The database is automatically deleted and memory is reclaimed when the last connection to the database closes."
# Let's create a fresh in-memory database.
conn = sqlobject.connectionForURI(db_uri)
sqlobject.sqlhub.processConnection = conn
Foo.createTable()
# Here, an exception is thrown:
sqlobject.dberrors.OperationalError: table foo already exists

I must have somehow gotten a connection to the same in-memory database that was created on the first call to connectionForURI(). After looking at dbconnection.py, I came up with an invasive method:

sqlobject.dbconnection.TheURIOpener.cachedURIs = {}
conn = sqlobject.connectionForURI(db_uri)
sqlobject.sqlhub.processConnection = conn
Foo.createTable()

It does what I need, but it doesn't seem like it's what SQLObject developers intended. Do you have any recommendations?

Maciej