mirror of
https://github.com/283375/arcaea-offline-ocr-model.git
synced 2025-04-21 21:40:17 +00:00
feat(db): record classify timestamp
This commit is contained in:
parent
08e97ab03e
commit
67a794f4f1
24
dbModels.py
24
dbModels.py
@ -1,4 +1,6 @@
|
|||||||
from sqlalchemy import CHAR, TEXT
|
from datetime import datetime
|
||||||
|
|
||||||
|
from sqlalchemy import CHAR, TEXT, TIMESTAMP, text, event, DDL
|
||||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
||||||
|
|
||||||
|
|
||||||
@ -27,3 +29,23 @@ class ClassifiedSample(ProjectBase):
|
|||||||
"sample_numpy_md5", CHAR(32), primary_key=True, unique=True
|
"sample_numpy_md5", CHAR(32), primary_key=True, unique=True
|
||||||
)
|
)
|
||||||
tag: Mapped[str] = mapped_column(TEXT(), primary_key=True)
|
tag: Mapped[str] = mapped_column(TEXT(), primary_key=True)
|
||||||
|
timestamp: Mapped[datetime] = mapped_column(
|
||||||
|
TIMESTAMP(), server_default=text("CURRENT_TIMESTAMP")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
event.listen(
|
||||||
|
ClassifiedSample.__table__,
|
||||||
|
"after_create",
|
||||||
|
DDL(
|
||||||
|
"""
|
||||||
|
CREATE TRIGGER IF NOT EXISTS update_classified_samples_timestamp
|
||||||
|
UPDATE OF sample_numpy_md5, tag
|
||||||
|
ON classified_samples
|
||||||
|
BEGIN
|
||||||
|
UPDATE classified_samples
|
||||||
|
SET timestamp = CURRENT_TIMESTAMP
|
||||||
|
WHERE sample_numpy_md5 = old.sample_numpy_md5;
|
||||||
|
END;"""
|
||||||
|
),
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user