EvgSkv / logica

Logica is a logic programming language that compiles to SQL. It runs on DuckDB, Google BigQuery, PostgreSQL and SQLite.
https://logica.dev
Apache License 2.0
1.74k stars 91 forks source link

Factor Out the Duplicate Lines #297

Open yilinxia opened 11 months ago

yilinxia commented 11 months ago

Hi @EvgSkv ,

When working with Logica scripts across multiple cells, I've identified a potential enhancement (unless it's already implemented).

For comparison, in Jupyter, when executing an SQL query, I can simply use:

%%sql sqlite:///my_database.db

However, with Logica, transferring records from tables to predicates requires more steps:

%%logica Q1_Result
@Engine("sqlite");
@AttachDatabase("mydata", "my_database.db");
Emp(..r) :- mydata.Employee(..r);
Dep(..r) :- mydata.Department(..r);

Each time we execute a query in a different cell, these duplicates lines have to be re-written. Perhaps we can adopt a similar approach as with SQL.