how to specify schema (Django)

373 views
Skip to first unread message

Ryan Roemmich

unread,
Mar 29, 2010, 12:16:21 PM3/29/10
to ibm_db
How do I specify the schema that contains my tables? It seems that no
matter what options I pass, the DB2 username is always prepended to
the table name.

So "SELECT ID, NAME FROM CUSTOMER" becomes "SELECT ID, NAME FROM
USERNAME.CUSTOMER"

I noticed that SQL_ATTR_CURRENT_SCHEMA is set to the username in
ibm_db_dbi.py, but even if I hard-code my schema, it still uses my
username.

Rahul

unread,
Mar 29, 2010, 3:19:33 PM3/29/10
to ibm_db
Hi Ryan,
Currently this is limitation of Django. You can't specify schema name
through Django.

What you want to do actually, please specify more clearly.

By default current schema is username, In dbi programming you can
change current schema by “set_current_schema()” method.

Thanks,
Rahul Priyadarshi

Rahul

unread,
Mar 31, 2010, 2:53:54 AM3/31/10
to ibm_db
Hi Ryan,

There are some workaround available in Django.

For e.g.
1)http://code.djangoproject.com/ticket/6064 is one which already
available, but to use this workaround there is some modification
needed in base.py of ibm_db_django apator. You can pick up modified
base.py from http://groups.google.com/group/ibm_db/web/base.py and
replace your existing base.py(at location '../site-packages/
ibm_db_django-0.2.0-py2.5.egg/ibm_db_django/') to this one.

2) http://code.djangoproject.com/ticket/6148 seems a more fuller
solution but not yet made it in.

3) Through model meta options you can set db_table metadata to
'”schema”.”table_name”'


<<<<
>I noticed that SQL_ATTR_CURRENT_SCHEMA is set to the username in
>ibm_db_dbi.py, but even if I hard-code my schema, it still uses my
>username.
<<<<

There is no need of setting SQL_ATTR_CURRENT_SCHEMA to username at
the time of creating connection . We will remove this from our next
release.


If you need any further clarifications or help then feel free to ask
me.

Thanks,
Rahul Priyadarshi

Reply all
Reply to author
Forward
0 new messages