Python Coding in Blender -
can me solve problem?
i'm using blender 2.74 , python 3.4 correct connector mysql. (by way, i'm beginner in using blender , python.)
what want make login ui , save inputted name database, code seems bit off or wrong. when try run code, didn't save value in variable, when try run in python ide (pycharm) worked.
here's code:
import sys sys.path.append('c:\python34\lib\site-packages') sys.path.append('c:\python34\dlls') import mysql.connector import bge bge.render.showmouse(1) cont = bge.logic.getcurrentcontroller() own = cont.owner sensor = cont.sensors ["enter"] pname = own.get("prptext") enter = cont.sensors ["enter"] numpadenter = cont.sensors ["numpadenter"] if enter.positive or numpadenter.positive: db = mysql.connector.connect(user='root', password='', host='localhost', database='dbname') cursor = db.cursor() cursor.execute("insert tblname value(%s", (pname)) #this other codes have tried far: #add_player = ("insert storymode " "(playername) " "values (%s)") #data_player = (pname) #cursor.execute(add_player, data_player) #cursor.execute("insert storymode" "(playername)" "values (%(pname)s)") db.commit() db.close()
the error is:
mysql.connector.errors.programmingerror: 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near '%s' @ line 1.
can tell need here? need add-ons work?
thank reading post , people give opinions.
looks you're missing closing parenthesis , 's' in you're sql insert statement?
insert tblname value (%s
needs
insert tblname values (%s)
Comments
Post a Comment