Relational/Logic Programming in Python?

Perhaps you should google "Logic Programming in Python". Pyke looks promising:

Pyke introduces a form of Logic Programming (inspired by Prolog) to the Python community by providing a knowledge-based inference engine (expert system) written in 100% Python.

Unlike Prolog, Pyke integrates with Python allowing you to invoke Pyke from Python and intermingle Python statements and expressions within your expert system rules.


As we are heading toward 2019, I recommend PySWIP over others recommended here. It is actively maintained and has an easy interface, unlike Pyke (9 years ago) or PyLog (6 years ago).


You may want to use pyDatalog, a logic programming library that I developed for Python implementing Datalog. It also works with SQLAlchemy to query relational databases using logic clauses.