{"id":35218655,"url":"https://github.com/elixir-sqlite/exqlite","last_synced_at":"2026-02-25T18:01:34.361Z","repository":{"id":39200365,"uuid":"340207483","full_name":"elixir-sqlite/exqlite","owner":"elixir-sqlite","description":"An SQLite3 driver for Elixir","archived":false,"fork":false,"pushed_at":"2025-12-22T16:13:25.000Z","size":14296,"stargazers_count":253,"open_issues_count":11,"forks_count":61,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-02T04:58:25.477Z","etag":null,"topics":["ecto","elixir","sqlite3"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/exqlite","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elixir-sqlite.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"warmwaffles"}},"created_at":"2021-02-18T23:44:09.000Z","updated_at":"2025-12-24T17:24:42.000Z","dependencies_parsed_at":"2023-02-15T04:15:48.883Z","dependency_job_id":"55bc10d6-940c-4b68-ad0d-b29714a93203","html_url":"https://github.com/elixir-sqlite/exqlite","commit_stats":null,"previous_names":[],"tags_count":117,"template":false,"template_full_name":null,"purl":"pkg:github/elixir-sqlite/exqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-sqlite%2Fexqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-sqlite%2Fexqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-sqlite%2Fexqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-sqlite%2Fexqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-sqlite","download_url":"https://codeload.github.com/elixir-sqlite/exqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-sqlite%2Fexqlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29833623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T17:57:15.019Z","status":"ssl_error","status_checked_at":"2026-02-25T17:56:11.472Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecto","elixir","sqlite3"],"created_at":"2025-12-29T23:23:35.738Z","updated_at":"2026-02-25T18:01:34.353Z","avatar_url":"https://github.com/elixir-sqlite.png","language":"C","funding_links":["https://github.com/sponsors/warmwaffles"],"categories":[],"sub_categories":[],"readme":"# Exqlite\n\n[![Build Status](https://github.com/elixir-sqlite/exqlite/workflows/CI/badge.svg)](https://github.com/elixir-sqlite/exqlite/actions)\n[![Hex Package](https://img.shields.io/hexpm/v/exqlite.svg)](https://hex.pm/packages/exqlite)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-blue.svg)](https://hexdocs.pm/exqlite)\n\nAn Elixir SQLite3 library.\n\nIf you are looking for the Ecto adapter, take a look at the\n[Ecto SQLite3 library][ecto_sqlite3].\n\nDocumentation: https://hexdocs.pm/exqlite\nPackage: https://hex.pm/packages/exqlite\n\n\n## Caveats\n\n* Prepared statements are not cached.\n* Prepared statements are not immutable. You must be careful when manipulating\n  statements and binding values to statements. Do not try to manipulate the\n  statements concurrently. Keep it isolated to one process.\n* Simultaneous writing is not supported by SQLite3 and will not be supported\n  here.\n* All native calls are run through the Dirty NIF scheduler.\n* Datetimes are stored without offsets. This is due to how SQLite3 handles date\n  and times. If you would like to store a timezone, you will need to create a\n  second column somewhere storing the timezone name and shifting it when you\n  get it from the database. This is more reliable than storing the offset as\n  `+03:00` as it does not respect daylight savings time.\n* When storing `BLOB` values, you have to use `{:blob, the_binary}`, otherwise\n  it will be interpreted as a string.\n\n## Installation\n\n```elixir\ndefp deps do\n  [\n    {:exqlite, \"~\u003e 0.27\"}\n  ]\nend\n```\n\n\n## Configuration\n\n### Runtime Configuration\n\n```elixir\nconfig :exqlite,\n    default_chunk_size: 100,\n    type_extensions: [MyApp.TypeExtension]\n```\n\n* `default_chunk_size` - The chunk size that is used when multi-stepping when\n  not specifying the chunk size explicitly.\n* `type_extensions`: An optional list of modules that implement the\n  Exqlite.TypeExtension behaviour, allowing types beyond the default set that\n  can be stored and retrieved from the database.\n\n### Compile-time Configuration\n\nIn `config/config.exs`,\n\n```elixir\nconfig :exqlite, force_build: false\n```\n\n* `force_build` - Set `true` to opt out of using precompiled artefacts.\n  This option only affects the default configuration. For advanced configuation,\n  this library will always compile natively.\n\n## Advanced Configuration\n\n### Defining Extra Compile Flags\n\nYou can enable certain features by doing the following:\n\n```bash\nexport EXQLITE_SYSTEM_CFLAGS=-DSQLITE_ENABLE_DBSTAT_VTAB=1\n```\n\nOr you can pass extra environment variables using the Elixir config:\n\n```elixir\nconfig :exqlite,\n  force_build: true,\n  make_env: %{\n    \"EXQLITE_SYSTEM_CFLAGS\" =\u003e \"-DSQLITE_ENABLE_DBSTAT_VTAB=1\",\n    \"V\" =\u003e \"1\"\n  }\n```\n\n### Listing Flags Used For Compilation\n\nIf you `export V=1` the flags used for compilation will be output to stdout.\n\n### Using System Installed Libraries\n\nThis will vary depending on the operating system.\n\n```bash\n# tell exqlite that we wish to use some other sqlite installation. this will prevent sqlite3.c and friends from compiling\nexport EXQLITE_USE_SYSTEM=1\n\n# Tell exqlite where to find the `sqlite3.h` file\nexport EXQLITE_SYSTEM_CFLAGS=-I/usr/include\n\n# tell exqlite which sqlite implementation to use\nexport EXQLITE_SYSTEM_LDFLAGS=-L/lib -lsqlite3\n```\n\nAfter exporting those variables you can then invoke `mix deps.compile`. Note if you\nre-export those values, you will need to recompile the `exqlite` dependency in order to\npickup those changes.\n\n### Database Encryption\n\nAs of version 0.9, `exqlite` supports loading database engines at runtime rather than compiling `sqlite3.c` itself.\nThis can be used to support database level encryption via alternate engines such as [SQLCipher](https://www.zetetic.net/sqlcipher/design)\nor the [Official SEE extension](https://www.sqlite.org/see/doc/trunk/www/readme.wiki). Once you have either of those projects installed\non your system, use the following environment variables during compilation:\n\n```bash\n# tell exqlite that we wish to use some other sqlite installation. this will prevent sqlite3.c and friends from compiling\nexport EXQLITE_USE_SYSTEM=1\n\n# Tell exqlite where to find the `sqlite3.h` file\nexport EXQLITE_SYSTEM_CFLAGS=-I/usr/local/include/sqlcipher\n\n# tell exqlite which sqlite implementation to use\nexport EXQLITE_SYSTEM_LDFLAGS=-L/usr/local/lib -lsqlcipher\n```\n\nOnce you have `exqlite` configured, you can use the `:key` option in the database config to enable encryption:\n\n```elixir\nconfig :exqlite, key: \"super-secret'\n```\n\n## Usage\n\nThe `Exqlite.Sqlite3` module usage is fairly straight forward.\n\n```elixir\n# We'll just keep it in memory right now\n{:ok, conn} = Exqlite.Sqlite3.open(\":memory:\")\n\n# Create the table\n:ok = Exqlite.Sqlite3.execute(conn, \"create table test (id integer primary key, stuff text)\")\n\n# Prepare a statement\n{:ok, statement} = Exqlite.Sqlite3.prepare(conn, \"insert into test (stuff) values (?1)\")\n:ok = Exqlite.Sqlite3.bind(statement, [\"Hello world\"])\n\n# Step is used to run statements\n:done = Exqlite.Sqlite3.step(conn, statement)\n\n# Prepare a select statement\n{:ok, statement} = Exqlite.Sqlite3.prepare(conn, \"select id, stuff from test\")\n\n# Get the results\n{:row, [1, \"Hello world\"]} = Exqlite.Sqlite3.step(conn, statement)\n\n# No more results\n:done = Exqlite.Sqlite3.step(conn, statement)\n\n# Release the statement.\n#\n# It is recommended you release the statement after using it to reclaim the memory\n# asap, instead of letting the garbage collector eventually releasing the statement.\n#\n# If you are operating at a high load issuing thousands of statements, it would be\n# possible to run out of memory or cause a lot of pressure on memory.\n:ok = Exqlite.Sqlite3.release(conn, statement)\n```\n\n### Using SQLite3 native extensions\n\nExqlite supports loading [run-time loadable SQLite3 extensions](https://www.sqlite.org/loadext.html).\nA selection of precompiled extensions for popular CPU types / architectures is\navailable by installing the [ExSqlean](https://github.com/mindreframer/ex_sqlean)\npackage. This package wraps [SQLean: all the missing SQLite functions](https://github.com/nalgeon/sqlean).\n\n```elixir\nalias Exqlite.Basic\n{:ok, conn} = Basic.open(\"db.sqlite3\")\n:ok = Basic.enable_load_extension(conn)\n\n# load the regexp extension - https://github.com/nalgeon/sqlean/blob/main/docs/re.md\nBasic.load_extension(conn, ExSqlean.path_for(\"re\"))\n\n# run some queries to test the new `regexp_like` function\n{:ok, [[1]], [\"value\"]} = Basic.exec(conn, \"select regexp_like('the year is 2021', ?) as value\", [\"2021\"]) |\u003e Basic.rows()\n{:ok, [[0]], [\"value\"]} = Basic.exec(conn, \"select regexp_like('the year is 2021', ?) as value\", [\"2020\"]) |\u003e Basic.rows()\n\n# prevent loading further extensions\n:ok = Basic.disable_load_extension(conn)\n{:error, %Exqlite.Error{message: \"not authorized\"}, _} = Basic.load_extension(conn, ExSqlean.path_for(\"re\"))\n\n# close connection\nBasic.close(conn)\n```\n\nIt is also possible to load extensions using the `Connection` configuration. For example:\n\n```elixir\narch_dir =\n  System.cmd(\"uname\", [\"-sm\"])\n  |\u003e elem(0)\n  |\u003e String.trim()\n  |\u003e String.replace(\" \", \"-\")\n  |\u003e String.downcase() # =\u003e \"darwin-arm64\"\n\nconfig :myapp, arch_dir: arch_dir\n\n# global\nconfig :exqlite, load_extensions: [ \"./priv/sqlite/\\#{arch_dir}/rotate\" ]\n\n# per connection in a Phoenix app\nconfig :myapp, Myapp.Repo,\n  database: \"path/to/db\",\n  load_extensions: [\n    \"./priv/sqlite/\\#{arch_dir}/vector0\",\n    \"./priv/sqlite/\\#{arch_dir}/vss0\"\n  ]\n```\n\nSee [Exqlite.Connection.connect/1](https://hexdocs.pm/exqlite/Exqlite.Connection.html#connect/1)\nfor more information. When using extensions for SQLite3, they must be compiled\nfor the environment you are targeting.\n\n## Why SQLite3\n\nI needed an Ecto3 adapter to store time series data for a personal project. I\ndidn't want to go through the hassle of trying to setup a postgres database or\nmysql database when I was just wanting to explore data ingestion and some map\nreduce problems.\n\nI also noticed that other SQLite3 implementations didn't really fit my needs. At\nsome point I also wanted to use this with a nerves project on an embedded device\nthat would be resiliant to power outages and still maintain some state that\n`ets` can not afford.\n\n\n## Under The Hood\n\nWe are using the Dirty NIF scheduler to execute the sqlite calls. The rationale\nbehind this is that maintaining each sqlite's connection command pool is\ncomplicated and error prone.\n\n\n## Compiling NIF for Windows\n\nWhen compiling on Windows, you will need the [Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) or equivalent toolchain. Please make sure you have the correct environment variables, including path to compiler and linker and architecture that matches `erl.exe` (likely x64).\n\nYou may also need to invoke `vcvarsall.bat amd64` _before_ running `mix`.\n\nA guide is available at [guides/windows.md](./guides/windows.md)\n\n## Contributing\n\nFeel free to check the project out and submit pull requests.\n\n[ecto_sqlite3]: \u003chttps://github.com/elixir-sqlite/ecto_sqlite3\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-sqlite%2Fexqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-sqlite%2Fexqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-sqlite%2Fexqlite/lists"}