Skip to content

Commit

Permalink
[NEEMInterface] allowed initialization from engine in addition to sql…
Browse files Browse the repository at this point in the history
…_uri.
  • Loading branch information
AbdelrhmanBassiouny committed Aug 25, 2024
1 parent 09f8a14 commit 3f9bf55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "NEEMQuery"
version = "1.1.3"
version = "1.1.4"
description = "Querying the NEEMs (Narrative Enabled Episodic Memories) datasbase"
readme = "README.md"
authors = [{ name = "Abdelrhman Bassiouny", email = "[email protected]" }]
Expand Down
10 changes: 7 additions & 3 deletions src/neem_query/neem_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,28 @@ class NeemInterface(NeemQuery):
and allows the user to use it directly for more complex and custom built queries.
"""

def __init__(self, sql_url: str):
def __init__(self, sql_url: Optional[str] = None, engine: Optional[Engine] = None):
"""
Initialize the NEEM interface.
:param sql_url: the URL to the NEEM database.
:param engine: the SQLAlchemy engine to use.
"""
super().__init__(sql_url)
super().__init__(sql_url, engine)

@classmethod
def from_neem_interface(cls, ni: 'NeemInterface') -> 'NeemInterface':
"""
Create a new instance of the NeemInterface from an existing NeemQuery.
:param ni: the NeemInterface instance.
"""
return cls(ni.engine.url.__str__().replace('***', 'password'))
return cls(engine=ni.engine)

def query_plan_of_neem(self, neem_id: int) -> NeemQuery:
"""
Get the complete cram plan of a neem given the neem ID.
:param neem_id: The id in (ID) column of the Neems table.
:return: The plan as a neem query.
"""
Expand Down

0 comments on commit 3f9bf55

Please sign in to comment.