On Fri, Oct 28, 2011 at 03:44:09PM +0200, jo wrote:
> I'm trying to write a script to access to PostgreSQL and Oracle, like this:
I'm not sure why you are doing it, but I have a situation where I have
to open one database directly and use the "normal" tg database at the
same time.  It's basically a migration or import script to take the old
database and convert it to a TG app.

The old database is opened like:

old_db = sqlalchemy.create_engine(sqlalchemy.engine.url.URL('dbtype',
   username='dbuser',password='dbpass', host='dbhost', database=('dbname')))
old_conn = old_db.connect()

Then to move from one to the other:

result = old_conn.execute("SELECT whatever FROM whatever etc")
    for row in result:
      blah = model.Blah(row[1], row[3], etc etc)
      model.DBSession.add(blah)

It might be completely off-track to what you are after. To have two
sessions running at the same time, my guess is you need to make two
DBSession objects.

 - Craig

-- 
Craig Small VK2XLZ   http://enc.com.au/          csmall at : enc.com.au
Debian GNU/Linux     http://www.debian.org/      csmall at : debian.org
old fingerprint:     1C1B D893 1418 2AF4 45EE  95CB C76C E5AC 12CA DFA5
NEW fingerprint:     5D2F B320 B825 D939 04D2  0519 3938 F96B DF50 FEA5

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en.

Reply via email to