unable to UPDATE, no errors, no update, what am I doing wrong?

I'm not able to do and update, there aren't any errors, the table doesn't get updated.

environment: server: Synology, MariaDB 10.3.24; destop: ubuntu 20, python3.8, mariadb-dev 10.3.29;

database, table websites: entry_id is int(11), auto_increment and primary key; url_base is varchar(255);

python3 code on desktop:

entry_id = 2
url_base = "example.com"

sql_update_website_url_base = ("UPDATE `websites` SET `url_base`=(?) WHERE `entry_id` = (?);")
sql_update_website_url_base_data = (url_base, entry_id)

connection = (..,autocommit = True) # this does connect
cursor = connection.cursor()

print("url_base: {}, entry_id: {}".format(url_base, entry_id))
response = cursor.execute(sql_update_website_url_base, sql_update_website_url_base_data)

print ("response: {}".format(response))

output:

 url_base: 'example.com', entry_id: 2
 response: None

Answer Answered by Daniel Black in this comment.

It looks like parentheses shouldn't be around the question mark.

Also sql_update_website_url_base should be just a string. Semicolons aren't needed in programming queries either (except for more complicated defining triggers/stored procedures etc).

so:

sql_update_website_url_base = "UPDATE websites SET url_base= ? WHERE entry_id = ?"

reference example.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.