←back to thread

171 points voat | 2 comments | | HN request time: 0.001s | source
Show context
foobarqux ◴[] No.42159700[source]
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?
replies(2): >>42161210 #>>42169938 #
kukkeliskuu ◴[] No.42161210[source]
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.
replies(1): >>42163817 #
foobarqux ◴[] No.42163817[source]
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.
replies(2): >>42174870 #>>42181953 #
evgskv ◴[] No.42174870[source]
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);
replies(1): >>42176667 #
1. foobarqux ◴[] No.42176667[source]
Thank you. You can't do Q(..r) in sqlite right? That's what I read in the tutorial.
replies(1): >>42179022 #
2. evgskv ◴[] No.42179022[source]
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!