You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create an object of the models using django's "objects.create()". You can give either a string or a datetime.time or datetime.datetime instance for the field.
Create a session using aldjemy.core.get_engine()
session.query(<model name>.sa).all() or <model name>.sa.query().all() gives the error
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2638, in all
return list(self)
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 90, in instances
util.raise_from_cause(err)
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 75, in instances
rows = [proc(row) for row in fetch]
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 437, in _instance
loaded_instance, populate_existing, populators)
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 498, in _populate_full
dict_[key] = getter(row)
File "~/.virtualenvs/test/local/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/types.py", line 413, in process
microseconds = value.microseconds
AttributeError: 'datetime.time' object has no attribute 'microseconds'
The text was updated successfully, but these errors were encountered:
This is possibly because Django stores MySQL's time as datetime.time overriding MySQLdb's way of saving as datetime.timedelta which is being given to SQLA. Since, SQLA is expecting only datetime.timedelta (all the mysql-python connector packages give datetime.timedelta), we are getting the above error.
Wow, that's quite interesting behavior. @tackler, do you have a suggestion on how we could address this, or is it best to leave it to user code? I tend to feel that making either Django or SQLAlchemy work differently than they were designed is unwise.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Steps to reproduce
aldjemy.core.get_engine()
session.query(<model name>.sa).all()
or<model name>.sa.query().all()
gives the errorThe text was updated successfully, but these errors were encountered: