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
Re: Connect to TWO databases [message #50823 is a reply to message #50813] Sat, 05 January 2019 11:47 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
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]);

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


Current Time: Sun Apr 28 01:44:38 CEST 2024

Total time taken to generate the page: 0.05534 seconds