neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
966 stars 232 forks source link

Allow agensgraph db to use neomodel #648

Closed gtnIIS closed 1 year ago

gtnIIS commented 2 years ago

The postgresql add-on agensgraph allows a user to have a RDB alongside a GDB within one database. It additionally allows querying via sql and cypher, just within the same query.

Trying to simply connect to a working agens-psql database through neomodel, I was already refused to do so (ValueError: Expecting url format: bolt://user:password@localhost:7687 got postgresql://postgres:mypassword@localhost:5432/mydb), as neomodel expects a bolt-type database url.

I am just at the start of exploring the universe around graph databases and OGMs but figure there is a great potential in opening up neomodel to not just pure neo4j databases.

mariusconjeaud commented 1 year ago

neomodel expects a bolt-type database url because it sits on top of the Neo4j Python driver, which connects to the database using the bolt or neo4j protocols.

For your suggestion to work, it would require adding a postgresql driver into the project, and then I'm not sure how supporting this would work ? neomodel builds Cypher queries and passes them to the database through the driver, would that work here ? Is that what you mean by "agensgraph supports querying via Cypher" ?

Feel free to share some proof of concept here if you want ! (It definitely looks like a potential big change though)

gtnIIS commented 1 year ago

I absolutely agree: that would be a huge modification.
It's actually been a while since I dipped into GDB and neo4j and as I didn't find a fitting solution for the problem at hand I did not persue the neo4j path any further. I therefore also stopped to explore the GDB universe for that matter.

Still I try to answer your questions, but only from a phaenomenological point of view - no testing involed...

neomodel builds Cypher queries and passes them to the database through the driver, would that work here ?

I think that might work. It does not need to be possible to mix up cypher and sql queries. A first version could just somehow detect which language the query is in (cypher or sql) and pass it to the right db (rel or graph) accordingly.

Is that what you mean by "agensgraph supports querying via Cypher" ?

well afaiu agensgraph accepts queries that are either written in sql or cypher of somehow even a mix of both. But here again: it's been a while and for persuing this any further one would have to read into agensgraph more. There was some documentation on agensgraph somewhere on their website, I think.

So, in conclusion my issue was merely a suggestion for admittetly a big change. And as I am neither really familiar with neomodel nor with agensgraph I can't tell you much more. You can keep the ticket open if you think it is a somewhat valueable idea. But you can also just close it, if you don't think this will be implemented anytime. :)

mariusconjeaud commented 1 year ago

OK then I am closing it, but thanks for the suggestion, and keep them coming ! I think given the state of the library, issues, PRs and plans for enhancement, we should keep it focused to Neo4j db.