使用以下两个游标会有什么不同 - 也就是说,django如何'初始化'它的游标和连接?
(1)Django默认
from django.db import connection
conn = connection
cursor = conn.cursor()
(2)自定义初始化
import MySQLdb
self.conn = MySQLdb.connect (
host = settings.DATABASES['default']['HOST'],
port = 3306,
user = settings.DATABASES['default']['USER'],
passwd = settings.DATABASES['default']['PASSWORD'],
db = settings.DATABASES['default']['NAME'])
self.conn.set_character_set('utf8')
self.cursor = self.conn.cursor()
self.cursor.execute("SET NAMES utf8")
self.cursor.execute('SET CHARACTER SET utf8;')
self.cursor.execute('SET character_set_connection=utf8;')