You need to always define the table so pydal knows it is there. That's just 
how pydal works. define_table only creates the table if it hasn't yet and 
migration is enabled.

A terça-feira, 6 de abril de 2021 à(s) 00:27:41 UTC+1, james c. escreveu:

> 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 pass, 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.
>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d11bb174-ca73-4c02-8bc7-ab1f7e2c1b9cn%40googlegroups.com.

Reply via email to