0

I have a Python application which utilizes SQLAlchemy to interface with a Postgres database. I am running into some issues saving a time object into the database.

I define two time columns where db is a SQLAlchemy object:

offHours                = db.Column(db.Time)
onHours                 = db.Column(db.Time)

Elsewhere in the code, I try to save a time value from a string:

offHours = "06:23"
onHours = "14:34"

Python then throws the following:

time data '06:23' does not match format '%HH:%MM'

I am confused by this error because the input is a valid 24 hour time. Additionally, the Python docs state that the correct formatter for a 24 hour timestamp is '%H:%M'. If this is the case, why is SQLAlchemy using '%HH:%MM' as it's time formatter?

In short, what am I doing wrong when saving these times? Is it my input or possibly some issue with my database configuration?

1
  • It may be that the quotes are required to match exactly. Commented Dec 17, 2015 at 20:46

1 Answer 1

1

Try saving datetime.time object and not string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.