temp.py 564 B

12345678910111213141516171819202122
  1. from databases import CRUD, SqlQuery, PhotoRecord
  2. from datetime import datetime
  3. session = SqlQuery()
  4. crud = CRUD(PhotoRecord)
  5. res = crud.read(session,conditions={"image_path":None})
  6. if res:
  7. time_str = "2025-03-26 19:29:39.954187"
  8. time_str_without_ms = time_str.split(".")[0]
  9. update = {
  10. "image_path": "sadasda",
  11. "image_index": 0,
  12. "photo_create_time": datetime.strptime(
  13. time_str_without_ms, "%Y-%m-%d %H:%M"
  14. ),
  15. }
  16. res.__dict__
  17. crud.update(
  18. session,
  19. res.id,
  20. **update,
  21. )