quda
Exqlite - make it work with existing Sqlite db
Hi,
I need to do the following tasks for me project using Sqlite3 existing dbs (files):
- connect to each of the Sqlite db/files in the repository
- list all the tables in the db.
- select (filter) some tables of interest
- for selected tables execute one query to extract some data (a very simple query such as SELECT items FROM table WHERE condition)
- return a map with all the collected results
So far, I managed (with difficulties) to install and configure Exqlite into the project.
I tried to follow the documentation Readme — Exqlite v0.38.0 and did:
{:ok, conn} = Exqlite.Sqlite3.open("path_to_one_db")
:ok = Exqlite.Sqlite3.execute(conn, "SELECT name FROM sqlite_master WHERE "type"='table'");
…and I got stuck. I don’t know how to use this library further on. The documentation is not very clear. There are no examples/tutorial online.
Next step is to get the list with the tables in the db.
Thanks for your help,
T.
PS: As you might have noted, I am quite new to Elixir. ![]()
Marked As Solved
kwando
Yep, I noticed that too. But I dont think it will be very hard to guess how it works ![]()
{:ok, db} = Exqlite.Basic.open(":memory:")
db
|> Exqlite.Basic.exec("create table books (title, author)")
db
|> Exqlite.Basic.exec("insert into books (title, author) values (?, ?)", ["test", "bob"])
db
|> Exqlite.Basic.exec("select * from books")
|> Exqlite.Basic.rows()
Results in this
{:ok, [["test", "bob"]], ["title", "author"]}
3
Also Liked
LostKobrakai
Popular in Questions
Hello, how can I check the Phoenix version ?
Thanks !
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









