dal has no introspection (i.e. it doesn't ask any "schema" information, nor
it tries to "calculate" it).
until you define your tables (or do DAL(...., auto_import=True)) DAL will
never know that a table exists.
On Friday, February 8, 2013 5:14:22 PM UTC+1, Alec Taylor wrote:
>
> Fully self contained example:
>
> >web2py.py -p 80 -S myapp2
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2013
> Version 2.4.1-alpha.2+timestamp.2013.02.07.05.36.19
> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
> PostgreSQL(pg8000), Oracle(cx_Oracle), MongoDB(pymongo), IMAP(imaplib)
> Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
> Type "copyright", "credits" or "license" for more information.
>
> In [1]: db = DAL('sqlite://myapp2.sqlite', pool_size=1,
> check_reserved=['all'])
>
> In [2]: db.tables
> Out[2]: []
>
> In [3]: db.define_table('examples_are_awesome', Field('foo'))
> Out[3]: <Table examples_are_awesome (id,foo)>
>
> In [4]: db.commit() # tried with + without this line
>
> In [5]: db.tables
> Out[5]: ['examples_are_awesome']
>
> In [6]: exit
>
> >web2py.py -p 80 -S myapp2
>
> web2py Web Framework
> Created by Massimo Di Pierro, Copyright 2007-2013
> Version 2.4.1-alpha.2+timestamp.2013.02.07.05.36.19
> Database drivers available: SQLite(sqlite3), MySQL(pymysql),
> PostgreSQL(pg8000),
> Oracle(cx_Oracle), MongoDB(pymongo), IMAP(imaplib)
> Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
> Type "copyright", "credits" or "license" for more information.
>
> In [1]: db = DAL('sqlite://myapp2.sqlite', pool_size=1,
> check_reserved=['all'])
>
> In [2]: db.tables()
> Out[2]: []
>
> On Sat, Feb 9, 2013 at 3:07 AM, Alec Taylor
> <[email protected]<javascript:>>
> wrote:
> > Experiencing some very strange errors on the latest web2py
> > (2.4.1-alpha.2+timestamp.2013.02.07.05.36.19).
> >
> > In my 'myapp2' application I have created a database, defined as
> follows:
> >
> > db = DAL('sqlite://mydb2.sqlite', pool_size=1, check_reserved=['all'])
> >
> > Now I defined some tables and inserted some data into it. (all from
> > the \modules folder)
> >
> > To confirm the tables and data exists I opened up the 5KB SQLite file
> > in two different external database programs, including the SQLite
> > Manager firefox extension.
> >
> > It was all there.
> >
> > But one of my functions in that same \modules folder couldn't find an
> > entry in the db (the db DAL object was sent from \controllers though).
> >
> > So from my code (and subsequent from $web2py.py -S myapp2) I ran
> > db.tables and got [].
> >
> > The exact same connection string is used throughout my code; so why
> > isn't this working?
> >
> > Thanks for all suggestions,
> >
> > Alec Taylor
> >
> > PS: Searching my entire web2py directory brought up only one sqlite
> > file named 'mydb2'
>
--
---
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].
For more options, visit https://groups.google.com/groups/opt_out.