python 创建触发器

# coding:utf-8
import MySQLdb

try:
    conn = MySQLdb.connect(host='xxx',
                       user='xxx',
                       passwd='xxx',
                       db='xxx',
                       port=3306,
                       charset="utf8")
except MySQLdb.Error, e:
    print 'MySQL Error %d:%s' % (e.args[0], e.args[1])

sql = """
CREATE TRIGGER xxx 
AFTER UPDATE ON xxx 
FOR EACH ROW
BEGIN
	insert into xxx values ('test');
END
"""

cursor = conn.cursor()
print cursor.execute(sql)

你可能感兴趣的:(Python)