News for hackers. Stuff that matters.
Re:Logica – Declarative logic programming language for data by foobarqux on Saturday November 16, 2024 @04:56PM (#42159700)
There don't seem to be any examples of how to connect to an existing (say sqlite) database even though it says you should try logica if "you already have data in BigQuery, PostgreSQL or SQLite,". How do you connect to an existing sqlite database?
Re:Logica – Declarative logic programming language for data by kukkeliskuu on Saturday November 16, 2024 @08:29PM (#42161210)
I was turned off by this at first, but then tried it out. These are mistakes in the documentation. The tools just work with PostgreSQL and SQLite without any extra work.
Re:Logica – Declarative logic programming language for data by foobarqux on Sunday November 17, 2024 @07:20AM (#42163817)
How do you connect to an existing database so that you can query it? There are examples of how you can specify an "engine" which will create a new database and use it as a backend for executing queries but I want to query existing data in an sqlite database.
Re:Logica – Declarative logic programming language for data by evgskv on Monday November 18, 2024 @12:48PM (#42174870)
To connect to a database file use:

  @AttachDatabase("db_prefix", "your_file.db");
  # Then you can query from it:
  Q(..r) :- db_prefix.YourTable(..r);
Re:Logica – Declarative logic programming language for data by foobarqux on Monday November 18, 2024 @03:35PM (#42176667)
Thank you. You can't do Q(..r) in sqlite right? That's what I read in the tutorial.
Re:Logica – Declarative logic programming language for data by evgskv on Monday November 18, 2024 @07:50PM (#42179022)
Ah, yes, you're right! Please do:

  # ...
  Q(your_column) :- example_db.YourTable(your_column:);
You can query multiple columns of course. Feel free to start threads in Discussions of the repo with whatever questions you have!
Re:Logica – Declarative logic programming language for data by kukkeliskuu on Tuesday November 19, 2024 @05:34AM (#42181953)
They are very responsive in the repo discussions, just ask questions there.
Re:Logica – Declarative logic programming language for data by evgskv on Monday November 18, 2024 @12:27AM (#42169938)
Yeah, we need better tutorials.

To use SQLite use @Engine("sqlite") imperative. And you can then connect to you database file with @AttachDatabase imperative.

For example if you have example.db file with Fruit table which has col0 column, then you can count fruits with program:

@Engine("sqlite"); @AttachDatabase("example", "example.db");

CountFruit(fruit) += 1 :- Fruit(fruit);

Then run CountFruit predicate.