Python MySQLdb- using multiple database tables in query -
i writing script in python , using mysqldb
package.
con1 = mdb.connect('127.0.0.1', 'root', '', 'teacher') con2 = mdb.connect('127.0.0.1', 'root', '', 'student', true)
i can execute query using single cursor in python. want write query use tables both database @ once. how can that?
was looking answer same question. found connecting without specifying database allow query multiple tables:
db = _mysql.connect('localhost', 'user', 'password')
then can query different tables different databases:
select table1.field1, table2.field2 database1.table1 inner join database2.table2 on database2.table2.join_field = database1.field1.join_field
and boom goes dynamite
Comments
Post a Comment