With a float value representing date and time with millisecond precision:
import datetime
float_time = 1485538757.29289
print datetime.datetime.fromtimestamp(float_time)
prints:
2017-01-27 09:39:17.292890
To store it in db:
from sqlalchemy import Column, DateTime
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class MyTable(Base):
__tablename__ = 'mytable'
time_created = Column(DateTime, nullable=False)
But saved value is rounded down to 2017-01-27 09:39:17
(from 2017-01-27 09:39:17.292890
). Is there is a solution?