| 123456789101112131415161718192021 |
- from databases import CRUD, SqlQuery, PhotoRecord
- from datetime import datetime
- session = SqlQuery()
- crud = CRUD(PhotoRecord)
- res = crud.read(session,conditions={"image_path":None})
- if res:
- time_str = "2025-03-26 19:29:39.954187"
- dt = datetime.strptime(time_str, "%Y-%m-%d %H:%M:%S.%f")
- # 格式化为年月日时分
- formatted_time_str = dt.strftime("%Y-%m-%d %H:%M:%S")
- update = {
- "image_path": "sadasda",
- "image_index": 0,
- "photo_create_time": datetime.strptime(formatted_time_str, "%Y-%m-%d %H:%M:%S"),
- }
- crud.update(
- session,
- res.id,
- **update,
- )
|