Hello Massimo,

thank you for your fast reply!

Honestly I don't think that this is related to my problem since I only
tried to demonstrate my problem with this example.

If I define a table in a model, I should be able to access this table
without any further configuration, right? So when I do the two
db.define_table()-statements (as shown in my first post), I should be
able to access the tables in a controller via db.album or db.track
respectively.  Unfortunately this is not the case and results in a
KeyError. When I do db.tables in a controller, only the auth_*-tables
are listed.

Is there any possibility to see, if web2py fails while initializing
the db-object? Setting the debug-level to 0 seems not the help since
it does not list errors concerning the database.

Regards

Benjamin

On 30 Aug., 16:58, mdipierro <[email protected]> wrote:
> > >>> db = DAL('sqlite://aubop.db')
> > >>> db.tables
> > []
> > That's strange, isn't it?
>
> this is fine. In fact even if the tables are in db, web2py does not
> discover them. You still need db.define_table(...) to inform web2py
> about them.
>
> I cannot say about the problem with the app, but could it be related
> to this?
>
> Massimo
>
> On Aug 30, 7:56 am, Benjamin Goll <[email protected]> wrote:
>
> > Hi there,
>
> > first of all I would like to thank you for this great software! It's
> > just so much fun to create powerful applications with it!
>
> > Unfortunately I ran into a really strange problem which I'm not able
> > to solve.
>
> > In the file models/database.py I define the following:
>
> > db = DAL('sqlite://aubop.db')
> > db.define_table('track', Field('title'), Field('artist'),
> > Field('length'), Field('filepath'))
> > db.define_table('album', Field('title'), Field('artist'),
> > Field('tracks', 'list:reference track'), Field('currentTrack',
> > 'reference track'), Field('currentPlaybackTime'), Field('rating',
> > 'integer'))
>
> > When I then try to access one of the two defined tables in a
> > controller, I receive a KeyError, telling me, that e.g. db.album
> > cannot be found.
> > When I open the database "aubop.db" manually via the commandline-
> > interface of sqlite3, I can see that the two tables have been created
> > in the database:
>
> > sqlite3 aubop.db
> > sqlite> .tables
> > album  track
>
> > The sql.log also tells me that the tables ahve been created
> > successfully.
>
> > I then started web2py in the shell-mode ("python web2py.py -S aubop -
> > M"):
>
> > >>> db.tables
>
> > ['auth_user', 'auth_group', 'auth_membership', 'auth_permission',
> > 'auth_event']>>> db = DAL('sqlite://aubop.db')
> > >>> db.tables
>
> > []
>
> > That's strange, isn't it?
>
> > Is there anybody who could help me?
>
> > Btw. access to a different sqlite-database works like a charm in a
> > second application I've created earlier.
>
> > Thanks in advance!
>
> > Regards
>
> > Benjamin

Reply via email to