Created
March 25, 2014 08:17
-
-
Save openinx/9757208 to your computer and use it in GitHub Desktop.
use a dict cursor.
This file contains hidden or 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 pymysql | |
from contextlib import contextmanager | |
#from contextlib import contextmanager | |
@contextmanager | |
def create_dict_cursor(): | |
with pymysql.connect(user='root', passwd='goodboy', host='127.0.0.1', cursorclass=pymysql.cursors.DictCursor) as cursor: | |
yield cursor | |
with create_dict_cursor() as cursor: | |
cursor.execute('show slave status') | |
for i in cursor: print i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment