I found a post saying this is not possible, but some code might be
useful for others

Any suggestions on using a (any) database on a readonly (compact
flash) drive. Is there a pure python database that works in memory.

from sqlalchemy import *
import threading
#The following line works fine
db = create_engine('sqlite:////test.db ')
#This one does not
#db = create_engine('sqlite://')
threads = []

db.echo = False  # Try changing this to True and see what happens

metadata = MetaData(db)

users = Table('users', metadata,
    Column('user_id', Integer, primary_key=True),
    Column('name', String(40)),
    Column('age', Integer),
    Column('password', String),
)
users.create()

i = users.insert()
i.execute(name='Mary', age=30, password='secret')
i.execute({'name': 'John', 'age': 42},
          {'name': 'Susan', 'age': 57},
          {'name': 'Carl', 'age': 33})

s = users.select()
rs = s.execute()

row = rs.fetchone()
print 'Id:', row[0]
print 'Name:', row['name']
print 'Age:', row.age
print 'Password:', row[users.c.password]

for row in rs:
    print row.name, 'is', row.age, 'years old'

def threadtest():
    global users
    s = users.select()
    rs = s.execute()

    row = rs.fetchone()
    print 'Id:', row[0]
    print 'Name:', row['name']
    print 'Age:', row.age
    print 'Password:', row[users.c.password]


t = threading.Thread(target = threadtest)
threads.append(t)


for t in threads:

    t.start()



for t in threads:
    t.join()

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to