Vivek
Vivek

Reputation: 4636

Torndb - Switch from one database to another

I am connecting to MySQL database using torndb in Python. Is there a way to switch between databases after connection is established? Like the select_db method?

Upvotes: 0

Views: 111

Answers (2)

ssskip
ssskip

Reputation: 259

Switch db:

conn.execute('use anotherDBName');

Upvotes: 2

Chuck Larson
Chuck Larson

Reputation: 1

this ultimately will be decided if the database is running on the same host and in the instance of MySQL. If it is running in the same instance you should be able to prefix your tables names with the database name. For example; "select splat from foo.bar where splat is not null" where foo is the database name and bar is the table name. Hope this helps!

Upvotes: 0

Related Questions