Skip to content

Instantly share code, notes, and snippets.

@ryoco
Created March 28, 2014 11:43
Show Gist options
  • Save ryoco/9830826 to your computer and use it in GitHub Desktop.
Save ryoco/9830826 to your computer and use it in GitHub Desktop.
use mysql-connector-python memo
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import mysql.connector
def sql_executer(sql):
con = mysql.connector.connect(
host = "localhost",
port = 3306,
db = "table",
user = "test",
passwd = "password",
buffered=True)
cur = con.cursor()
cur.execute(sql)
res = cur.fetchall()
cur.close()
con.close()
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment