Skip to content

Query Engines

Logica is native to the SQL ecosystem; it is designed to compile to SQL and run on data that customers already have in their databases. As of January 2025, Logica runs on DuckDB, Google BigQuery, SQLite, and PostgreSQL. In this guide, we will be using SQLite, a highly efficient, free database that is omnipresent and part of the Python standard library.

To specify that you would like to run your Logica program in SQLite, include the line @Engine("sqlite"); in your program. For example, you could write the following into file socrates.l :

@Engine("sqlite");
Human("Socrates");
Mortal(x) :- Human(x);

Now you can find out who is mortal with the command:

$ logica socrates.l run Mortal

and it will run with the built-in SQLite engine.

The line @Engine("sqlite"); that you have added looks like a fact, and it is. The predicate here is @Engine. Special predicates that start with @Engine are called imperatives. These predicates are used to command the Logica engine on what to do.

TIP

If you are not familiar with predicates, facts, or rules, no worries, we will walk you through the concepts one by one.