Answer the question
In order to leave comments, you need to log in
How to make insert here?
Hello! I am using python+firebird. I want to create a new record in the table
. The table has a trigger for generating ID and date:
AS
BEGIN
if(new.id is null) then new.id=gen_id(d_gen_commands,1);
new.datetime="now";
post_event "d_new_command";
END
cur.execute(f"insert into d_commands values {(num, date_and_time, 1, 'open_door,0', -1062731554)}")
cur.execute(f"insert into d_commands (executor, text, phis_addr) values ({int(1)}, {str(action)}, {int(-1062731554)})")
('Error while preparing SQL statement:\n- SQLCODE: -206\n- Dynamic SQL Error\n- SQL error code = -206\n- Column unknown\n- OPEN_DOOR\n- At line 1, column 63', -206, 335544569)
Answer the question
In order to leave comments, you need to log in
Akina , Gleb Lukashonok , please do not build SQL queries using string formatting unless absolutely necessary.
Use placeholders and may Bobby Tables be with you .
cur.execute("insert into d_commands (executor, text, phis_addr) values (?, ?, ?)", (1, str(action), -1062731554))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question