v2.0.2: fix SQLite — UUID in all INSERTs, now()→datetime, ::jsonb cleanup
Deploy contracts-flask / validate (push) Successful in 0s

This commit is contained in:
2026-07-16 07:29:51 +04:00
parent 9e22182f9a
commit b8340a0637
7 changed files with 56 additions and 44 deletions
+7 -4
View File
@@ -1,14 +1,17 @@
"""Documents CRUD."""
import uuid
from db.connection import query, execute, execute_returning
def insert(filename, mime_type, original_bytes, status="uploaded", batch_id=None, zip_source=None, content_hash=None):
"""Insert document, return row dict."""
return execute_returning(
"""INSERT INTO documents (filename, mime_type, original_bytes, status, batch_id, zip_source, content_hash)
VALUES (%s, %s, %s, %s, %s, %s, %s) RETURNING *""",
(filename, mime_type, original_bytes, status, batch_id, zip_source, content_hash),
doc_id = str(uuid.uuid4())
execute(
"""INSERT INTO documents (id, filename, mime_type, original_bytes, status, batch_id, zip_source, content_hash)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)""",
(doc_id, filename, mime_type, original_bytes, status, batch_id, zip_source, content_hash),
)
return get(doc_id)
def get(doc_id):