Skip to content

Instantly share code, notes, and snippets.

@openinx
Created March 25, 2014 08:17
Show Gist options
  • Save openinx/9757208 to your computer and use it in GitHub Desktop.
Save openinx/9757208 to your computer and use it in GitHub Desktop.
use a dict cursor.
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