Python Forum
PyMySQL - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: PyMySQL (/thread-319.html)



PyMySQL - Dean Stackhouse - Oct-05-2016

Hey,

I have PyMySQL working however the result its printing has an unexpected character.

#!/usr/bin/python

import pymysql.cursors

connection = pymysql.connect(
    host='localhost',
    user='test',
    password='test',
    db='test',
    charset='utf8',
    cursorclass=pymysql.cursors.DictCursor
)

try:
    with connection.cursor() as cursor:
        cursor.execute("SELECT * FROM `test` WHERE `id`=`1`")
        result = cursor.fetchone()
        print(result)

finally:
    connection.close()
These are the results i get.

{u'row1': 100, u'row2': 100}

All of the results i get have a u before each result. I could always just cut up the string but i was more so wondering what the u means.

Thanks


RE: PyMySQL - micseydel - Oct-05-2016

It's unicode. The u isn't actually part of your string, much like a bracket character isn't part of a list.