python & DAL & SQLite - Trying to use persistent data across python sessions

Viewed 52

I am trying to access persistent data saved in an sqlite.db file without wiping it out. I start an interactive session with just python and no web2py and enter the following:

from pydal import DAL, Field

db = DAL('sqlite://storage.sqlite', folder='home/cryptoj/venv', auto_import=True)

db.define_table('persons', Field('name'))

Now I can create and save table data - after db.commit() the table is saved and I can read the table with DB Browser for SQLite. I can enter additional data from DB Browser and it too can be read in the interactive python session.

I close the terminal. I close DB Browser. Then I open DB Browser and the data is all there. Yet, when I go through the above commands, in a new session, it appears the db.define_table is dropping the existing data stored in storage.sqlite.

On the 2nd time, opening a new terminal, if I don't define_table again there are errors and the existing data can not be read in the interactive session.

Thank you in advance for any recommendations, James

0 Answers
Related