I tried this solution in many ways but without success.

2015-01-19 16:34:45,599 INFO sqlalchemy.engine.base.Engine {}
2015-01-19 16:34:45,599 INFO sqlalchemy.engine.base.Engine SELECT 
CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2015-01-19 16:34:45,599 INFO sqlalchemy.engine.base.Engine {}
2015-01-19 16:34:45,600 INFO sqlalchemy.engine.base.Engine show 
standard_conforming_strings
2015-01-19 16:34:45,600 INFO sqlalchemy.engine.base.Engine {}
2015-01-19 16:34:45,601 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2015-01-19 16:34:45,601 INFO sqlalchemy.engine.base.Engine SET search_path 
TO veterfarma
2015-01-19 16:34:45,601 INFO sqlalchemy.engine.base.Engine {}
 ENDPOINT anagraficaArticolo {'action': u'GetCategoriaArticolo'}
2015-01-19 16:34:45,602 INFO sqlalchemy.engine.base.Engine SET search_path 
TO veterfarma,promogest2
2015-01-19 16:34:45,602 INFO sqlalchemy.engine.base.Engine {}
2015-01-19 16:34:45,602 INFO sqlalchemy.engine.base.Engine SELECT 
ferchim.categoria_articolo.id AS ferchim_categoria_articolo_id, 
ferchim.categoria_articolo.denominazione AS 
ferchim_categoria_articolo_denominazione, 
ferchim.categoria_articolo.denominazione_breve AS 
ferchim_categoria_articolo_denominazione_breve 
FROM ferchim.categoria_articolo
2015-01-19 16:34:45,602 INFO sqlalchemy.engine.base.Engine {}
[pid: 12785|app: 0|req: 76/76] 192.168.1.3 () {36 vars in 719 bytes} [Mon 
Jan 19 16:34:45 2015] GET /pg/ac_Articolo/GetCategoriaArticolo?tipo=simple 
=> generated 574 bytes in 12 msecs (HTTP/1.1 200) 2 headers in 80 bytes (1 
switches on core 0)


Here, in the log i change the search_path to veterfarma that is the news 
scheme but the query is performed to ferchim. that is the first schema i 
choose on the app start. 

i have 

    __table__ = Table('foo', metadata,  schema=schema,  autoload=True ) 

in every Class Foo(Base)

if i don't use schema in the definition i have a 

2015-01-19 16:48:20,698 INFO sqlalchemy.engine.base.Engine {'table_name': 
u'foo'}
Traceback (most recent call last):
[...]
   File 
"/usr/lib64/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 
54, in cache
    ret = fn(self, con, *args, **kw)
  File 
"/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py", 
line 1933, in get_table_oid
    raise exc.NoSuchTableError(table_name)
NoSuchTableError: foo


i tried deleting the Articolo module from sys.modules but the project has 
140 tables 20 in the promogest2 ( main scheme ) and the rest in the others.
with another very small project this way works but it is very ugly solution.

Using one schema it worked well in the last 8 years. 

sorry to bother you again

F. 


 

Il giorno lunedì 19 gennaio 2015 02:43:06 UTC+1, Michael Bayer ha scritto:
>
> the ‘schema’ is a fixed name within the Table object.  If you want to work 
> on a different schema on each request, set up search_path on the connection 
> at the start of the request: 
>
> http://www.postgresql.org/docs/9.1/static/ddl-schemas.html#DDL-SCHEMAS-PATH 
>
>
>
>
> M3nt0r3 <m3n...@gmail.com <javascript:>> wrote: 
>
> > Hi, 
> > 
> > I have a postgresql with many scheme, every schema is a company. 
> > I am trying to change the scheme to match the user is making the login 
> or change the schema per subdomain. ( at wsgi level it already worked ) 
> > when the first user make the login is ok , meta and mappers are there 
> "mapped" to the right scheme but when i try to change scheme, (making some 
> Metadata.clear() or other stuff) the mapper still return the old scheme. I 
> think it is not possibe to map ALL the schemas in the DB because of the 
> same name of the tables and of the Mapper Classes too. 
> > i am  searching for some documentation, some advice 
> > 
> > thanks 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "sqlalchemy" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to sqlalchemy+...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:>. 
> > Visit this group at http://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to