On Feb 10, 2009, at 3:20 PM, nosklo wrote:

>
> Hi all!
>
> I have a MSSQL SERVER I want to use sqlalchemy on, because there are
> some old databases in there and legacy applications and we can't
> migrate the data for now. (although a migration is planned and
> SQLAlchemy is helping a lot)
>
> The server has two Databases (table collections) lets call them DataA
> and DataB. Both are on the same MSSQL SERVER.
>
> If i create a MSSQL engine like this:
>
> import sqlalchemy as sa
> e = sa.create_engine('mssql://myuser:sec...@myserver/DataA',
> echo=True)
> e.execute('SELECT * FROM TableInA')
>
> The engine points to the 'DataA' database, so that works. I get a
> result object with all rows from TableInA;
>
> But I still can access/join with a table in DataB by running:
>
> e.execute('SELECT * FROM DataB.dbo.TableInB')
>
> That works too, so I get rows from TableInB which is in DataB, a
> different database from the one I used when creating the engine
> object. I can even JOIN tables from DataB with tables in DataA, no
> problem.
>
> Question is: How can I do that in a sa.Table constructor?
> I have tried:
>
> sa.Table('DataB.dbo.TableInB', metadata, ....)
> sa.Table('TableInB', metadata, ...., schema='DataB.dbo')
>
> And both failed. Is there a way to map tables from both databases
> using the same engine? So I can do a JOIN between the tables?

you should use the "schema" argument.  Define "failed" ?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to