v2.0.2: fix SQLite — UUID in all INSERTs, now()→datetime, ::jsonb cleanup
Deploy contracts-flask / validate (push) Successful in 0s
Deploy contracts-flask / validate (push) Successful in 0s
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user