I usually do this:
db=DAL('sqlite://storage.db')
auth=Auth(globals(),db)
auth.define_tables()
user_id = (auth.user and auth.user.id) or 0
userdb = DAL('sqlite://db_for_user_%i.db' % user_id)
Mind that you lose the ability to access userdb from appadmin.
On Dec 9, 12:59 pm, Vidul Petrov <[email protected]> wrote:
> > I am not sure what you mean what "names are not known in advance".
>
> I agree, the question was not appropriate.
> I was wondering how to create an unique SQLDB per user.
>
> The case is as follows:
> - one application
> - many databases, many users
> - relation between user:database - 1:1
>
> On Dec 9, 8:22 pm, mdipierro <[email protected]> wrote:
>
> > You can connect to multiple db
>
> > dba=DAL(...)
> > dbb=DAL(...)
> > dbc=DAL(...)
>
> > I am not sure what you mean what "names are not known in advance".
>
> > On Dec 9, 12:17 pm, Vidul Petrov <[email protected]> wrote:
>
> > > Thank you, Massimo.
>
> > > Is there any way an application to hold multiple SQLDB objects,
> > > pointed from variables, whose names are not known in advance?
>
> > > On Dec 9, 8:10 pm, mdipierro <[email protected]> wrote:
>
> > > > You cannot store a db in session because SQLDB requires a connection.
> > > > The connection is closed (or recycled) when the reponse is completed
> > > > and the transaction is committed.
>
> > > > On Dec 9, 11:52 am, Vidul Petrov <[email protected]> wrote:
>
> > > > > Is SQLDB object creation in session possible?
>
> > > > > The following code did not work for me (I didn't manage to use session
> > > > > before SQLDB):
>
> > > > > from gluon.tools import *
>
> > > > > if not session.db:
> > > > > session.db = DAL()
>
> > > > > My intention is to store multiple SQLDB objects in one application,
> > > > > one per user.
>
>
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.