(table_name: str, data: dict[str, Any])
| 116 | |
| 117 | |
| 118 | def insert_record(table_name: str, data: dict[str, Any]) -> int: |
| 119 | check_identifier(table_name) |
| 120 | con = get_connection() |
| 121 | placeholders = ', '.join(['?'] * len(data)) |
| 122 | sql = f'INSERT INTO {table_name} VALUES (NULL, {placeholders})' |
| 123 | cursor = con.execute(sql, tuple(data.values())) |
| 124 | pk = cursor.lastrowid |
| 125 | con.commit() |
| 126 | cursor.close() |
| 127 | return pk |
| 128 | |
| 129 | |
| 130 | def fetch_record(table_name: str, pk: int) -> sqlite3.Row: |