Last active
August 29, 2015 14:22
-
-
Save iku000888/ccf5e59f2fdc0d563319 to your computer and use it in GitHub Desktop.
Functioning mysql.connector example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Simple demonstration of inserting a utf-8 string into | |
#mysql table | |
import mysql.connector | |
# -*- coding: utf-8 -*- | |
cnx = mysql.connector.connect(user='root', password='root', | |
host='127.0.0.1', | |
database='EN_JAP') | |
cursor = cnx.cursor() | |
add_word = ("INSERT INTO word_mp " | |
"(english_word, japanese_word) " | |
"VALUES (%s, %s)") | |
data_word = ('flower','花') | |
cursor.execute(add_word,data_word) | |
cnx.commit() | |
cursor.close() | |
cnx.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment