0

I'm having some trouble with my code.

    db = pymysql.connect('localhost', 'root', 'password', 'stockdb')
    cursor = db.cursor()
    sql = "INSERT INTO kospitbl (code,name) VALUES ('" + code + "','" + name + "')"
    try:
        cursor.execute(sql)
        db.commit()
    except:
        db.rollback()

    db.close()

The problem here is that the 'name' variable is in Korean. When running this code, the sql is not executed. However, when I execute the sql code directly into the MySQL db server, it works just fine.

I've tried setting up my charset to 'utf8' when getting the db connection, but that wouldn't work either. I'd appreciate any help regarding charset issues.

0 Answers0