Bob

An in-memory database that is empty to start, loaded with data, and goes away 
when the connection goes away is exactly what I'm after.  The code and the 
program for an in-memory database works perfectly.  

However, a web version using webpy doesn't work - the error message is that it 
cannot find the database table.  After reading your note, it hit me that an 
execution thread is created by pysqlite and another thread by webpy and hence 
webpy is not seeing the table.  What a pain!

Dinesh


----- Original Message ----- 
From: bob gailer 
To: Dinesh B Vadhia 
Cc: tutor@python.org 
Sent: Saturday, April 12, 2008 11:25 AM
Subject: Re: [Tutor] in-memory pysqlite databases


Dinesh B Vadhia wrote: 
  Say, you have already created a pysqlite database "testDB".  In a Python 
program, you connect to the database as:

  > con = sqlite3.connect("testDB")
  > cur = con.cursor()

  To use a database in memory (ie. all the 'testDB' tables are held in memory) 
the pysqlite documentation says the declaration is:

  > con = sqlite3.connect(":memory:")
  > cur = con.cursor()

  But, this can't be right as you're not telling Python/pysqlite which database 
to keep in memory. 

The documentation says "Creating an in-memory database". That means (to me) a 
new database that is memory resident and as consequence is empty to start and 
goes away when the connection goes away.

I don't see any easy way to load a file-based db into a memory-based one. Seems 
like you'd need to create all the tables in memory, then run select cursors to 
retrieve from the file-based db and insert the rows into the memory-based db 
tables

Why do you want it in memory?

[snip]

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to