1616from typing import Any , Dict , Iterator , List , Optional , Union
1717
1818from .connection import Connection
19- from .models import (
20- MemgraphConstraint ,
21- MemgraphConstraintExists ,
22- MemgraphConstraintUnique ,
23- MemgraphIndex ,
24- )
19+ from .models import MemgraphConstraint , MemgraphConstraintExists , MemgraphConstraintUnique , MemgraphIndex
2520
2621__all__ = ("Memgraph" ,)
2722
@@ -62,20 +57,20 @@ def execute_and_fetch(self, query: str, connection: Connection = None) -> Iterat
6257 connection = connection or self ._get_cached_connection ()
6358 return connection .execute_and_fetch (query )
6459
65- def execute_query (self , query : str , connection : Connection = None ) -> None :
60+ def execute (self , query : str , connection : Connection = None ) -> None :
6661 """Executes Cypher query without returning any results."""
6762 connection = connection or self ._get_cached_connection ()
68- connection .execute_query (query )
63+ connection .execute (query )
6964
7065 def create_index (self , index : MemgraphIndex ) -> None :
7166 """Creates an index (label or label-property type) in the database"""
7267 query = f"CREATE INDEX ON { index .to_cypher ()} "
73- self .execute_query (query )
68+ self .execute (query )
7469
7570 def drop_index (self , index : MemgraphIndex ) -> None :
7671 """Drops an index (label or label-property type) in the database"""
7772 query = f"DROP INDEX ON { index .to_cypher ()} "
78- self .execute_query (query )
73+ self .execute (query )
7974
8075 def get_indexes (self ) -> List [MemgraphIndex ]:
8176 """Returns a list of all database indexes (label and label-property types)"""
@@ -96,12 +91,12 @@ def ensure_indexes(self, indexes: List[MemgraphIndex]) -> None:
9691 def create_constraint (self , index : MemgraphConstraint ) -> None :
9792 """Creates a constraint (label or label-property type) in the database"""
9893 query = f"CREATE CONSTRAINT ON { index .to_cypher ()} "
99- self .execute_query (query )
94+ self .execute (query )
10095
10196 def drop_constraint (self , index : MemgraphConstraint ) -> None :
10297 """Drops a constraint (label or label-property type) in the database"""
10398 query = f"DROP CONSTRAINT ON { index .to_cypher ()} "
104- self .execute_query (query )
99+ self .execute (query )
105100
106101 def get_constraints (self ) -> List [Union [MemgraphConstraintExists , MemgraphConstraintUnique ]]:
107102 """Returns a list of all database constraints (label and label-property types)"""
@@ -130,7 +125,7 @@ def ensure_constraints(self, constraints: List[Union[MemgraphConstraintExists, M
130125
131126 def drop_database (self ):
132127 """Drops database by removing all nodes and edges"""
133- self .execute_query ("MATCH (n) DETACH DELETE n" )
128+ self .execute ("MATCH (n) DETACH DELETE n" )
134129
135130 def _get_cached_connection (self ) -> Connection :
136131 """Returns cached connection if it exists, creates it otherwise"""
0 commit comments