Skip to content Skip to sidebar Skip to footer

Pymysql Return Error Sql Syntax

On py3, i use pymysql module for connecting to MySQL. i write function into Database() class like this where MySQLi run on constructor: def add_user_to_database(self, id, first_nam

Solution 1:

When you build a query with string interpolation, you can get escape/quoiting issues, however it's easy to use a parametrised query:

sql = "INSERT INTO `users` (`id`, `first_name`) VALUES (%s, %s)"
cursor.execute(sql, (id, first_name)

Post a Comment for "Pymysql Return Error Sql Syntax"