From a9d5a8762da563d1f3eeb00816d1f6d298ad72cd Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 13 Jan 2024 13:26:48 +0100 Subject: [PATCH] updated maildb state --- states/maildb/templates/maildb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/states/maildb/templates/maildb.py b/states/maildb/templates/maildb.py index ec0485c..d091e4f 100644 --- a/states/maildb/templates/maildb.py +++ b/states/maildb/templates/maildb.py @@ -50,7 +50,8 @@ def CreateDB(conn, cursor): def InsertMail(conn, cursor, sender, recipient, content): try: - cursor.execute(f"INSERT INTO mail (sender, recipient, content) values ('{sender}','{recipient}','{content}');") + cursor.execute("PREPARE InsertMail as INSERT INTO mail (sender, recipient, content) values ($1, $2, $3);") + cursor.execute("EXECUTE InsertMail (%s, %s, %s);", (sender, recipient, content)) conn.commit() except Exception as e: print(e)