52186/connect-to-two-databases
I am trying to connect to two databases using Python and, also, use tables from both of the databases. How can I do this? Is the following code correct?
con = mdb.connect(host=MY_HOST, user=MY_USER, passwd=MY_PASS, db1=MY_DB1, db2=MY_DB2)
If you don't specify the database in your connect call, you can write queries against multiple databases at once.
db = _mysql.connect('localhost', 'user', 'passwd')
then
SELECT u.*, i.* FROM db1.users u LEFT JOIN db2.items i ON u.id = i.user_id
Hey Radhika, To communicate any database with Python ...READ MORE
Hello @kartik, To sync the two models to ...READ MORE
db = MySQLdb.connect(host="localhost", # ...READ MORE
It shouldn't matter whether the connection is ...READ MORE
Sorted!!!! just found the solution, 1 - apparently ...READ MORE
connect mysql database with python import MySQLdb db = ...READ MORE
Very similar to mysqldb but better than ...READ MORE
The connection string passed to psycopg2.connect is ...READ MORE
you are passing the parsed datetime object to ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.