Answer the question
In order to leave comments, you need to log in
sqlite3 syntax error?
def add_server(self, server_id, server_name, ignore_id = 0, population_id = 0):
if self.is_server_exist(server_id): print('Server is already in table'); return
self.cur.execute('INSERT OR REPLACE INTO servers (server_id, server_name, channel_id_for_monitoring_population, role_id_for_ignoring_score) VALUES ({}, {}, {}, {})'.format(server_id, server_name, ignore_id, population_id))
self.conn.commit()
print(f'Server {server_name} was added')
self.cur.execute("""CREATE TABLE IF NOT EXISTS servers (
server_id INT PRIMARY KEY,
server_name TEXT,
channel_id_for_monitoring_population INT,
role_id_for_ignoring_score INT);
""")
Answer the question
In order to leave comments, you need to log in
Every week I write that you should not form queries by concatenation, interpolation and string formatting. Use prepared statements and you will be happy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question