From the command-line:
mysql -u username -ppassword database < filename
From within MySQL:
Log into mysql i.e. mysql -u -p [database]
mysql> source [filename]
From the command-line:
mysql -u username -ppassword database < filename
From within MySQL:
Log into mysql i.e. mysql -u -p [database]
mysql> source [filename]
# -*- coding: utf-8 -*-
import MySQLdb, MySQLdb.cursors
db_connection = MySQLdb.connect(user="root", passwd="pass",
db="mydb", cursorclass = MySQLdb.cursors.DictCursor,
use_unicode = True)
db = db_connection.cursor()
# assuming that id=1271 has a val that has utf "ยต" in it
sql = """
SELECT *
FROM vals
WHERE id = 1271
""" % ()
db.execute(sql)
r = db.fetchall()[0]
val = r['val']
print val
print type(val)