On 6/2/15 5:52 AM, 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).\
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...
it sounds like at some point your program is using "self.connection"
without emitting that "USE" statement, or you have some kind of routine
that is undoing the "USE" and perhaps multiple callers and/or threads
are accessing "self.connection" at the same time.
--
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.