Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Connect to TWO databases
Connect to TWO databases [message #50813] Tue, 01 January 2019 15:21 Go to next message
deep is currently offline  deep
Messages: 195
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

I remember there was example to connect to two databases/sessions. I could not locate it.

I want to copy some tables from Oracle to PostgreSQL,

Any example using TWO SQL sessions simultaneously will be useful.


Warm Regards

Deepak
Re: Connect to TWO databases [message #50823 is a reply to message #50813] Sat, 05 January 2019 11:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
deep wrote on Tue, 01 January 2019 15:21
Hi,

I remember there was example to connect to two databases/sessions. I could not locate it.

I want to copy some tables from Oracle to PostgreSQL,

Any example using TWO SQL sessions simultaneously will be useful.


It is basically the same, the only thing to keep in mind:

Sql is using default database "SQL" if no session is specified for it. When you have 2 databases, this is obviosly impossible. So you need to specify at least one of them for each Sql you are using. Perhaps it is even prudent to stop using global SQL. Anyway, it might look like this:

MySQLSession mysql_session;
Sqlite3Session sqlite3_session;
... login etc...

SQL = mysql_session; // MySQL will be default

Sql mysql; // default is MySQL, no need to specify session
Sql sqlite3(sqlite3_session); // explicitly specify that this is connected to sqlite3

mysql * Select(FOO).From(BAR);
while(mysql.Fetch())
    sqlite3 * Insert(BAR)(FOO, mysql[0]);

Re: Connect to TWO databases [message #50898 is a reply to message #50823] Sun, 13 January 2019 09:04 Go to previous message
deep is currently offline  deep
Messages: 195
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Mirek,

Thanks. It works!

Sorry I could not check it earlier.



Warm Regards

Deepak

[Updated on: Sun, 13 January 2019 09:04]

Report message to a moderator

Previous Topic: [SOLVED] How to join two tables from two schemas with SqlExp
Next Topic: MySQL link error
Goto Forum:
  


Current Time: Tue Aug 20 20:12:21 CEST 2019

Total time taken to generate the page: 0.00909 seconds