According to the book, it only tries the second db if the first fails. You can also do random, round-robin, or controller/action dependent connections if desired.
On Wednesday, December 8, 2010 9:45:07 PM UTC-5, Bruno Rocha wrote: web2py will stop at the first it can connect? or it will try the second even if connected succesfully with the first? I am asking that because my localhost has access to my remote db, so if my list is ['remotedb','localdb'], I will always connect with the first even working locally. 2010/12/9 mdipierro <[email protected]> +1 Mind that the uri can also be a list DAL([uri1,uri2,uri3]) and web2py will try them all. This is designed for replicated databases. On Dec 8, 7:50 pm, Bruno Rocha <[email protected]> wrote: > I always use: > > if request.env.server_name=='rochacbruno.local' or > request.env.http_host.split(':')[0]=='127.0.0.1': > db=DAL(<mylocaldb>) > else: > db=DAL(<myproductiondb>) > > This is useful because I transfer my files by sftp or ssh, and I dont need > to change the db everytime. > > 2010/12/8 mdipierro <[email protected]> > > > > > If you just have > > > production=True > > if production: > > db=DAL('sqlite://production.sqlite') > > else: > > db=DAL('sqlite://test.sqlite') > > > when you switch to production=False, it will recreate the missing > > tables in test.sqlite. > > > On Dec 8, 8:10 am, Vidul <[email protected]> wrote: > > > I'd like to create a testing database which contains the same tables > > > as the production one. > > > This is the code I came up with: > > > > for i in db_test.tables: > > > db_test[i].drop() > > > db_test.commit() > > > > for i in db.tables: > > > db_test.define_table(i, db[i]) > > > db_test.commit() > > > > Is there a better way? > > > > Thank you for the help. > > -- > > Bruno Rochahttp://about.me/rochacbruno/bio -- Bruno Rochahttp://about.me/rochacbruno/bio

