Try to replace dash ("-") with uderscore ("_") in the variable names i.e. db_cats
Il giorno sabato 12 marzo 2016 15:10:33 UTC+1, Shayn Raney ha scritto: > > I would like to implement something like this to use two sqlite3 > databases. I've tried to create the following within a new model via the > web admin gui and did not see the new tables under the 'Available Databases > and Tables' appadmin page. Does the 'Available Databases and Tables' page > only show the items within the 'storage.sqlite' file? > > db-cats = DAL('sqlite://cats.sqlite', poolsize = 1) > > db-cats.define_table('names', > Field('name', 'string'), > Field('age', 'integer'), > Field('account', 'integer') > ) > > db-cats.define_table('owner', > Field('fname', 'string'), > Field('lname', 'string'), > Field('phone', 'string') > ) > > > > > On Wednesday, January 2, 2013 at 9:05:27 AM UTC-8, Alec Taylor wrote: >> >> >> >> On Wed, Jan 2, 2013 at 10:53 PM, Simon Ashley <greg...@gmail.com> wrote: >> >>> Ok then, should this work? >>> (Version 2.3.2 (2012-12-17 15:03:30) stable, source, nightly build, from >>> 12/31) >>> >>> *Connection* >>> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) >>> db1 = DAL('mysql://root:www@localhost:3306/xxx', migrate=True, >>> fake_migrate=False, check_reserved=['common','mysql']) #www and xxx's >>> have been blanked (place markers) >>> >>> *Model* >>> db.define_table('luPace', >>> Field('Description','string', label='Pace'), >>> Field('icon','string', length=100), >>> Field('bgcolor','string'), >>> Field('fgcolor','string')) >>> >>> db1.define_table('luStart1', >>> Field('Description','string', label='Start'), >>> Field('icon','string'), >>> Field('bgcolor','string'), >>> Field('fgcolor','string')) >>> >>> *Controller* >>> def pace(): >>> tablel = SQLFORM.grid(db.luPace) >>> return locals() >>> >>> def start(): >>> tablel = SQLFORM.grid(db.luStart1) >>> return locals() >>> >> >> You'll want to change the first line of that second function: >> >> tablel = SQLFORM.grid(db1.luStart1) >> >> >> >>> Execute the following: >>> >>> *pace ..* >>> >>> as expected >>> >>> >>> *start ....* >>> >>> Traceback (most recent call last): >>> >>> File "C:\web2py15\gluon\restricted.py", line 212, in restricted >>> >>> exec ccode in environment >>> File "C:/web2py15/applications/test1/controllers/test.py" >>> <http://127.0.0.1:8000/admin/default/edit/test1/controllers/test.py>, line >>> 13, in <module> >>> >>> File "C:\web2py15\gluon\globals.py", line 193, in <lambda> >>> >>> self._caller = lambda f: f() >>> >>> File "C:/web2py15/applications/test1/controllers/test.py" >>> <http://127.0.0.1:8000/admin/default/edit/test1/controllers/test.py>, line >>> 9, in start >>> >>> tablel = SQLFORM.grid(db.luStart1) >>> >>> File "C:\web2py15\gluon\dal.py", line 7255, in __getattr__ >>> >>> return ogetattr(self, key) >>> AttributeError: 'DAL' object has no attribute 'luStart1' >>> >>> *luStart1* works from appadmin >>> >>> >>> -- >>> >>> >>> >>> >> >> -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.