On 6/4/15 3:28 AM, eli rashlin wrote:
yes but the schema is different for each run, I dont want it to be hard coded into the table definition.

that we don't support. Issue https://bitbucket.org/zzzeek/sqlalchemy/issue/2685/default-schema-schema-translation-map-as proposes this.

To get this now you need to write a before_cursor_execute() event that does a search and replace on the SQL string; use a schema name like "CHANGEME" so it's easy to spot. The event gets the name of the schema it should use from a thread local variable that you set on the outside.








On Tuesday, June 2, 2015 at 12:52:22 PM UTC+3, eli rashlin wrote:

    Hi,

    I have a very strange behavior, I have a program that uses bulk
    insertions to the DB.
    for some reason the process which iterate on one table and create
    bulk and insert into another table fails with the error of  'No
    database selected'.


    this is how I bind the session:

    
#-------------------------------------------------------------------------------------------------------------------
    # use_db:
    #        this method will return a session reference
    #         using this DB
    
#-------------------------------------------------------------------------------------------------------------------

        def use_db(self, new_db_name):
            self.connection.execute("USE %s" % (new_db_name))
            session_ref = sessionmaker(bind = self.connection,
    expire_on_commit=False)
            self.session_cover_tst = session_ref()
            return self.session_cover_tst



    engine = connection_engine.use_db(db_name)
    count_sig =
    
engine.query(func.count(distinct(signals_table.Signals.sig_value)).label('count_sig')).\
             filter(signals_table.Signals.message_id == msg_row.id
    <http://msg_row.id>).\
             filter(signals_table.Signals.signal_id == sig_id).\
             group_by(signals_table.Signals.signal_id).\
             one()[0]


    now the table Signals is huge (500M records), but the table is
    indexed and everything is working great for a few rounds and then
    I'm getting the error  'No database selected'  and it fails...

--
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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
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