Hi,

I am using sqlalchemy in my pyramid application. I have situation here, 
where I need to map a table on the fly in the application during run time. 
I also dont want to re-map all tables, there are some table which are 
defined using a declarative base. I need those mapping to remain as is. How 
can we do this?. Does clear_mappers() remove even declarative base mapping ?


DBSession = 
scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
Base = declarative_base()

class User(Base):
    __tablename__ ="youzer"
    uid = Column(Integer,autoincrement=True, primary_key=True)
    uname = Column(Text,nullable=False,index=True)
 
Just one of the tables as example. There are many tables that I need to map 
for different request

class GroupOrder()
     gtid = Column(Integer, autoincrement=True,primary_key=True) 
     group_id = Column(Integer, 
ForeignKey("group.gid",ondelete="CASCADE"),nullable=False) 
     ...
     ...

These groups can grow huge , so decision was made to shard these group 
based on a hash. These are similar structured tables , with different names.

Tables
group_order_<shard1>
group_order_<shard1>
group_order_<shard1>

table_object = Table(<shard table name with similar structure>, 
Base.metadata,
        Column('gtid', Integer, primary_key=True),
        Column('group_id', ForeignKey('group.gid',ondelete="CASCADE"), 
nullable=False),
        ....
        ...


Based on the request, I need to map the GroupOrder to the concerned table 
and process the request.

This is a uwsgi application will the clear_mapper affect other worker 
threads. ?

Srikanth Bemineni






-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to