0

I am getting errors while inserting value to a newly added column.

import mysql.connector
mydb = mysql.connector.connect(
    host = 'localhost',
    username = 'rt',
    password = 'rt',
    database = 'demo'
)
mycursor = mydb.cursor()
sql = "INSERT INTO customers_1 (Address) VALUES(%s)"
val = ("Karthik")
mycursor.execute(sql,val)
mydb.commit()
print(mycursor.rowcount, "record inserted.")
3
  • Which errors do you get? Commented Apr 4, 2024 at 14:52
  • Please add the full error log to the question. Commented Apr 4, 2024 at 14:53
  • You're missing a comma to make it a tuple: val = ("Karthik",) Commented Apr 4, 2024 at 15:02

1 Answer 1

0

are you trying to update the column for all entries?

UPDATE customers_1
SET Address = %s
WHERE condition;

w3schools

i'm aware i'm possibly misunderstanding the question asked

Sign up to request clarification or add additional context in comments.

1 Comment

They still need to correct the tuple syntax.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.