Datetime Field ?
2 2

4 posts in this topic

Hello,

I need to sync parts my ftrack database with parts of my inhouse database. For this reason I need support for a timestamp (Date AND time) which gets updated when a field has last been changed.
How can i put datetime information into the ftrack database?
The custom_attributes support the date field and if i query it i receive an arrow object. But when i try to set it to a new datetime i can only set it with a date but not with a time information.

if i try to set it with time information i get an error:
ServerError: Server reported error: IntegrityError(Custom attribute value for "my_time_stamp" must be a valid date. Got '2018-06-28T18:13:14.043000'.)

 

Here is some code snippet:

my_object = session.query("MyObjectType where name is MyName").first()


my_time_stamp = my_object["custom_attributes"]["my_time_stamp"]
log.debug("My Time Stamp: {}".format(my_time_stamp)) # >>> 2018-06-28T00:00:00+00:00

arrow_now = arrow.utcnow()
log.debug("Arrow datetime: {}".format(arrow_now.datetime)) # >>> 2018-06-28 18:04:48.799000+00:00
log.debug("Arrow date: {}".format(arrow_now.date())) # >>> 2018-06-28

my_object["custom_attributes"]["my_time_stamp"] = arrow_now.date()

 

I hope someone can guide me to the right direction.

Best,

Lukas

Share this post


Link to post
Share on other sites
13 hours ago, lukas g said:

ServerError: Server reported error: IntegrityError(Custom attribute value for "my_time_stamp" must be a valid date. Got '2018-06-28T18:13:14.043000'.)

 

If you do not call .date() on the arrow_now, does it work then?

There is a 'Event' schema that can be used:

session.query('Event where parent_id is "fc625b24-fd16-11e3-9bfd-04011030cf01" order by created_at desc limit 1').one()

 

Share this post


Link to post
Share on other sites

Hi Mattias,

the event query tip was very helpful! Thanks a lot for that. Now i am able to compare all DB entries with each other based on their latest update :)

Regarding the arrow date issue. I was not able to get it to work with my custom attribute (But right now i don't rely on the custom date attribute anymore as i am using the nice event query)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
2 2