Reputation: 194
I have a table in MySql in one server and a table in PostgreSQL in another server. I want use use JOIN operation with those tables. Is there any way to join the columns? If not, is there any way to print the rows in same order? Please help!!
Upvotes: 4
Views: 2592
Reputation: 316
You can use Materialize to achieve this.
Here is a sample demo project that you can run to see this in action:
You can find the code for the demo project and how to run it on GitHub here:
https://github.com/bobbyiliev/materialize-tutorials/tree/main/mz-join-mysql-and-postgresql
Upvotes: 2
Reputation: 585
Hope this reference helps.
Yes, it is possible to work with multiple databases at the same time but you're looking in the wrong place. psycopg2 is just a library that simplifies accessing and manipulating data coming out of PostgreSQL but it doesn't go far beyond what you can do with psql. What you're looking to do you can solve on the database level by using Foreign Data Wrappers.
This does become more complicated in your schema definition but brings remote tables from host some.other.server database remote_db to appear as though they live on localhost in database local_db.... More: https://dba.stackexchange.com/a/120682/197899
Upvotes: 1
Reputation: 246083
Use mysql_fdw to define the MySQL table as a foreign table in PostgreSQL. Then you can join it with the PostgreSQL table in PostgreSQL.
Upvotes: 5