Hi,
I am new to this lib and I played around with timestamps in my graph.
When I run my example below I get the following error:
gqlalchemy\connection.py", line 92, in execute_and_fetch
cursor.execute(query)
mgclient.DatabaseError: Function 'datetime.datetime' doesn't exist.
I tested it with gqlalchemy 1.3.1.
Example:
from datetime import datetime
from gqlalchemy import Memgraph, Node, Relationship, Field
class User(Node):
id: str = Field(index=True, unique=True, db=db)
name: str = Field()
timestamp: datetime = Field()
User(id="1", name="myUser", timestamp=datetime.now()).save(db)
After running into this error I did a little bit of debugging.
I printed the underlying cypher statement:
MATCH (node: User) WHERE node.id = '1' RETURN node;
CREATE (node:User) SET node.id = '1' SET node.name = 'myUser' SET node.timestamp = datetime.datetime(2022, 7, 24, 0, 32, 51, 583238) RETURN node;
Here one can see 'datetime.datetime(2022, 7, 24, 0, 32, 51, 583238)'. This seems to be the datetime object representation instead of 'localDateTime(...)'. See:
|
assert to_cypher_value(localdatetime) == "localDateTime('1999-12-12T12:12:12')" |
I also found out that 'to_cypher_value(...)' is never called in my case.
If I switch the type to 'str' instead of 'datetime' I do not get any error.
Btw., nice lib :-)!
BR,
Alexander