ian-andrich / PythonPengines

A Python interface to the Prolog pengines library. Makes it exceedingly easy to call out to SWI-Prolog within Python!
MIT License
12 stars 9 forks source link

Question: how to best consult large databases #21

Open andreaBelmont opened 4 years ago

andreaBelmont commented 4 years ago

I am not quite sure how does this work:

factory = PengineBuilder(urlserver="http://localhost:4242", destroy=False, srctext=src, ask=q)

Do I always need to load the database each time I run a query? Is there any better way to consult a database of prolog facts? I looked in the examples but I could not really find an example of :- consult('file.pl')

Thanks for helping

ian-andrich commented 4 years ago

Correct me if I'm wrong.

But shouldn't the Pengines side of things be responsible for consulting?

This is basically just an API for working with an already running Pengines service.

So by my reading -- you are correct -- it is "wasteful" to include the consult in the Python side of the service, though you have the right to do so.

However, most (sane, well scoped) use cases that would probably be a code smell.

ian-andrich commented 4 years ago

Thinking a bit more, consulting is a happy path -- would you mind adding an example to the readme that handles this case once you are happy with your approach?