Merge pull request #7 from intoverflow/tcarstens/query-params

Updated _create_entry to use sqlite's parameter syntax for values
This commit is contained in:
Ambertide
2021-12-22 05:30:28 +03:00
committed by GitHub
2 changed files with 3 additions and 2 deletions

View File

@@ -51,7 +51,7 @@ table name `student` and rows `student_id`, `student_name` with datatypes
integer and text, respectively. The default value for `student_name` is integer and text, respectively. The default value for `student_name` is
`John Smith`. `John Smith`.
##Basic Usage ## Basic Usage
### Entry manipulation ### Entry manipulation

View File

@@ -27,7 +27,8 @@ def _create_entry(self) -> None:
try: try:
cur.execute(f"INSERT INTO {table_name}(" cur.execute(f"INSERT INTO {table_name}("
f"{', '.join(item[0] for item in kv_pairs)})" f"{', '.join(item[0] for item in kv_pairs)})"
f" VALUES ({', '.join(_convert_sql_format(item[1]) for item in kv_pairs)});") f" VALUES ({', '.join('?' for item in kv_pairs)})",
[_convert_sql_format(item[1]) for item in kv_pairs])
self.__setattr__("obj_id", cur.lastrowid) self.__setattr__("obj_id", cur.lastrowid)
con.commit() con.commit()
except IntegrityError: except IntegrityError: