Skip to content

Instantly share code, notes, and snippets.

@aguegu
Created September 29, 2013 08:23
Show Gist options
  • Save aguegu/6750398 to your computer and use it in GitHub Desktop.
Save aguegu/6750398 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import os
import cx_Oracle
reload(sys)
sys.setdefaultencoding('utf-8')
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.AL32UTF8'
conn = cx_Oracle.connect('username/password@address:port/database')
cursor = conn.cursor()
cursor.execute('SELECT T.NICKNAME FROM T_SM_USER T WHERE T.ID = 1')
row = cursor.fetchall()
print "%r" % row[0][0]
print row[0][0].decode("utf-8")
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment