mahdi salarabedi
mahdi salarabedi

Reputation: 1

How can i insert a single data into a Mysql table using Python?

I have tried this code but i receive the 1064 error.

x_1=**********    
t_2=(x_1)
cursor.execute('insert into informations' '(password)' 'values (%s)',t_2)

Upvotes: 0

Views: 39

Answers (1)

cestMoiBaliBalo
cestMoiBaliBalo

Reputation: 146

cursor.execute('insert into informations (password) values (?)', (x_1,))

would be a better syntax.

Just one string including the whole statement and using a question mark as placeholder for the value to insert.

The most important is to define the single value into a tuple.

Upvotes: 1

Related Questions