can someone help me solve this problem?
I'm using Blender 2.74 and Python 3.4 with the correct connector to MySQL. By the way, I'm just a beginner in using Blender and Python. What I want is to make a login UI and save the inputted name into the database, but my code seems a bit off or totally wrong. When I run the code, it didn't save the value in the variable, but when i try to run it in python IDE it worked.
Here's the code:
import sys
sys.path.append('C:\Python34\Lib\sitepackages')
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 ["input"]
#this variable suppose to get the inputted name
pname = ""
db = mysql.connector.connect(user='root', password='', host='localhost', database='database')
cursor = db.cursor()
add_player = ("INSERT INTO table " "(PlayerName) " "VALUES (%s)")
data_player = (pname)
cursor.execute(add_player, data_player)
#The 2nd one that i tried, and the same error
cursor.execute("INSERT INTO storymode" "(PlayerName)" "VALUES (%(pname)s)")
db.commit()
db.close()
My questions are: Why it always have an error saying syntax error near the %s;Am I missing something in the code or do i need an add-on/s to make it work properly?Thank you very much for reading my post and for the people who will give their opinions.