-
-
Save methane/068a269fc804fa2e39a53be3c55e275a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado_mysql | |
from tornado import ioloop, gen | |
@gen.coroutine | |
def main(): | |
print("trying to connect to MySQL") | |
conn = yield tornado_mysql.connect(host='127.0.0.1', user='root', db='test') | |
cur = conn.cursor() | |
yield cur.execute("CREATE TABLE tornado_test (a int)") | |
query = "INSERT INTO tornado_test (a) values (42)" | |
yield cur.execute(query) # this is getting executed! | |
yield cur.close() | |
yield conn.commit() | |
yield conn.close_async() # tried conn.close() as well, Both throws an exception: | |
print('end') | |
ioloop.IOLoop.current().run_sync(main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment