Skip to content

Instantly share code, notes, and snippets.

@iku000888
Last active August 29, 2015 14:22
Show Gist options
  • Save iku000888/ccf5e59f2fdc0d563319 to your computer and use it in GitHub Desktop.
Save iku000888/ccf5e59f2fdc0d563319 to your computer and use it in GitHub Desktop.
Functioning mysql.connector example
#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