Skip to content

python connection error after successful connection #77

Description

@dewaldpieterse

Using the latest memgraph v3.6 running in docker on another linux machine.
I can successfully connect to memgraph using memgraph lab from my laptop.
Using python 3.12.11 on windows 11 with gqalchemy 1.8.0.
When running a python script from the same laptopm either within spyder IDE or directly in python get a GQLAlchemyWaitForConnectionError:

 172 hashcheck = list(
    173     Match()
    174     .node(variable="m", labels="ProjLibPropNode")
    175     .to(relationship_type="PROPERTIES_OF")
    176     .node(variable="n", labels="ProjLibMainNode")
    177     .where(item="m.PropStatus", operator=Operator.EQUAL, literal="Current")
    178     .and_where(item="n.SBRGNo", operator=Operator.EQUAL, literal=DocID)
    179     .return_("m.Hash")
--> 180     .execute()
    181     )
    183 dbhashlen = len(hashcheck)
    184 if dbhashlen == 0:

File ~\anaconda3\envs\py312\Lib\site-packages\gqlalchemy\query_builders\declarative_base.py:1458, in DeclarativeBase.execute(self)
   1456 query = self._construct_query()
   1457 if self._fetch_results:
-> 1458     return self._connection.execute_and_fetch(query)
   1459 else:
   1460     return self._connection.execute(query)

File ~\anaconda3\envs\py312\Lib\site-packages\gqlalchemy\vendors\database_client.py:58, in DatabaseClient.execute_and_fetch(self, query, parameters, connection)
     54 def execute_and_fetch(
     55     self, query: str, parameters: Dict[str, Any] = {}, connection: Connection = None
     56 ) -> Iterator[Dict[str, Any]]:
     57     """Executes Cypher query and returns iterator of results."""
---> 58     connection = connection or self._get_cached_connection()
     59     return connection.execute_and_fetch(query, parameters)

File ~\anaconda3\envs\py312\Lib\site-packages\gqlalchemy\vendors\database_client.py:138, in DatabaseClient._get_cached_connection(self)
    136 """Returns cached connection if it exists, creates it otherwise."""
    137 if self._cached_connection is None or not self._cached_connection.is_active():
--> 138     self._cached_connection = self.new_connection()
    140 return self._cached_connection

File ~\anaconda3\envs\py312\Lib\site-packages\gqlalchemy\vendors\memgraph.py:230, in Memgraph.new_connection(self)
    221 """Creates new Memgraph connection."""
    222 args = dict(
    223     host=self._host,
    224     port=self._port,
   (...)
    228     client_name=self._client_name,
    229 )
--> 230 return MemgraphConnection(**args)

File ~\anaconda3\envs\py312\Lib\site-packages\gqlalchemy\connection.py:78, in MemgraphConnection.__init__(self, host, port, username, password, encrypted, client_name, lazy)
     74 super().__init__(
     75     host=host, port=port, username=username, password=password, encrypted=encrypted, client_name=client_name
     76 )
     77 self.lazy = lazy
---> 78 self._connection = self._create_connection()

File ~\anaconda3\envs\py312\Lib\site-packages\gqlalchemy\exceptions.py:244, in connection_handler.<locals>._handler(*args, **kwargs)
    242 time.sleep(current_delay)
    243 if time.perf_counter() - start_time >= timeout:
--> 244     raise GQLAlchemyWaitForConnectionError from ex
    246 current_delay *= backoff

GQLAlchemyWaitForConnectionError:

The memgraph log shows the gqlalchemy connection:

[2025-10-10 13:04:17.528] [memgraph_log] [info] Client connected 'GQLAlchemy'
[2025-10-10 13:04:17.579] [memgraph_log] [debug] [Run - memgraph] 'CREATE INDEX ON :ProjLibMainNode(SBRGNo);'
[2025-10-10 13:04:17.687] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibMainNode) ASSERT EXISTS (n.SBRGNo);'
[2025-10-10 13:04:17.787] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibMainNode) ASSERT n.SBRGNo IS UNIQUE;'
[2025-10-10 13:04:17.891] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibMainNode) ASSERT EXISTS (n.Link);'
[2025-10-10 13:04:17.998] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.Dependability);'
[2025-10-10 13:04:18.094] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.Revision);'
[2025-10-10 13:04:18.193] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.Name);'
[2025-10-10 13:04:18.291] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.Author);'
[2025-10-10 13:04:18.389] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.PropStatus);'
[2025-10-10 13:04:18.485] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.ReviewStatus);'
[2025-10-10 13:04:18.584] [memgraph_log] [debug] [Run - memgraph] 'CREATE INDEX ON :ProjLibPropNode(Hash);'
[2025-10-10 13:04:18.684] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT EXISTS (n.Hash);'
[2025-10-10 13:04:18.781] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:ProjLibPropNode) ASSERT n.Hash IS UNIQUE;'
[2025-10-10 13:04:18.882] [memgraph_log] [debug] [Run - memgraph] 'CREATE INDEX ON :RefLibNode(SBRGNo);'
[2025-10-10 13:04:18.980] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.SBRGNo);'
[2025-10-10 13:04:19.079] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT n.SBRGNo IS UNIQUE;'
[2025-10-10 13:04:19.176] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Dependability);'
[2025-10-10 13:04:19.276] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Name);'
[2025-10-10 13:04:19.374] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Title);'
[2025-10-10 13:04:19.473] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Year);'
[2025-10-10 13:04:19.574] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.ItemType);'
[2025-10-10 13:04:19.672] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Author);'
[2025-10-10 13:04:19.722] [memgraph_log] [debug] [Run - memgraph] 'SHOW REPLICATION ROLE' - {source:"lab-system"}
[2025-10-10 13:04:19.722] [memgraph_log] [debug] [Run - memgraph] 'SHOW STORAGE INFO' - {source:"lab-system"}
[2025-10-10 13:04:19.722] [memgraph_log] [debug] [Run - memgraph] 'SHOW LICENSE INFO' - {source:"lab-system"}
[2025-10-10 13:04:19.726] [memgraph_log] [debug] [Run - memgraph] 'SHOW REPLICAS' - {source:"lab-system"}
[2025-10-10 13:04:19.728] [memgraph_log] [debug] [Run - memgraph] 'MATCH (APP_INTERNAL_EXEC_VAR) return COUNT(APP_INTERNAL_EXEC_VAR) as cnt' - {source:"lab-system"}
[2025-10-10 13:04:19.728] [memgraph_log] [debug] [Run - memgraph] 'SHOW INDEX INFO' - {source:"lab-system"}
[2025-10-10 13:04:19.728] [memgraph_log] [debug] [Run - memgraph] 'SHOW TRIGGERS' - {source:"lab-system"}
[2025-10-10 13:04:19.728] [memgraph_log] [debug] [Run - memgraph] 'SHOW CONSTRAINT INFO' - {source:"lab-system"}
[2025-10-10 13:04:19.766] [memgraph_log] [debug] [Run - memgraph] 'CREATE INDEX ON :RefLibNode(Hash);'
[2025-10-10 13:04:19.862] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Hash);'
[2025-10-10 13:04:19.961] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT n.Hash IS UNIQUE;'
[2025-10-10 13:04:20.060] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.PropStatus);'
[2025-10-10 13:04:20.158] [memgraph_log] [debug] [Run - memgraph] 'CREATE CONSTRAINT ON (n:RefLibNode) ASSERT EXISTS (n.Link);'
[2025-10-10 13:04:20.304] [memgraph_log] [trace] Storage GC on 'memgraph' started [periodic]
[2025-10-10 13:04:20.304] [memgraph_log] [trace] Storage GC on 'memgraph' finished [periodic];

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions