{"id":23326131,"url":"https://github.com/duckdb/duckdb-sqlite","last_synced_at":"2025-04-12T19:41:38.400Z","repository":{"id":37205826,"uuid":"416315721","full_name":"duckdb/duckdb-sqlite","owner":"duckdb","description":"DuckDB extension to read and write to SQLite databases","archived":false,"fork":false,"pushed_at":"2025-04-03T18:31:11.000Z","size":3086,"stargazers_count":226,"open_issues_count":22,"forks_count":26,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-03T23:09:09.379Z","etag":null,"topics":["duckdb","sql","sqlite"],"latest_commit_sha":null,"homepage":"https://duckdb.org/docs/extensions/sqlite","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/duckdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2021-10-12T11:51:06.000Z","updated_at":"2025-04-03T18:31:16.000Z","dependencies_parsed_at":"2024-02-21T09:36:23.136Z","dependency_job_id":"026d18ad-9430-4c59-8dab-c910e8d3c2e3","html_url":"https://github.com/duckdb/duckdb-sqlite","commit_stats":null,"previous_names":["duckdb/sqlite_scanner","duckdblabs/sqlite_scanner"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdb%2Fduckdb-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdb%2Fduckdb-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdb%2Fduckdb-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duckdb%2Fduckdb-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duckdb","download_url":"https://codeload.github.com/duckdb/duckdb-sqlite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625028,"owners_count":21135509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["duckdb","sql","sqlite"],"created_at":"2024-12-20T19:07:53.890Z","updated_at":"2025-04-12T19:41:38.374Z","avatar_url":"https://github.com/duckdb.png","language":"C","readme":"# DuckDB SQLite extension\n\nThe SQLite extension allows DuckDB to directly read and write data from a SQLite database file. The data can be queried directly from the underlying SQLite tables. Data can be loaded from SQLite tables into DuckDB tables, or vice versa.\n\n## Reading Data from SQLite\n\nTo make a SQLite file accessible to DuckDB, use the `ATTACH` command, for example with the bundled `sakila.db` file:\n\n```sql\nATTACH 'data/db/sakila.db' AS sakila;\nUSE sakila;\n```\n\nThe tables in the file can be read as if they were normal DuckDB tables, but the underlying data is read directly from the SQLite tables in the file at query time.\n\n```sql\nSHOW TABLES;\n```\n\nYou can query the tables using SQL, e.g. using the example queries from sakila-examples.sql\n\n```sql\nSELECT cat.name category_name, \n       Sum(Ifnull(pay.amount, 0)) revenue \nFROM   category cat \n       LEFT JOIN film_category flm_cat \n              ON cat.category_id = flm_cat.category_id \n       LEFT JOIN film fil \n              ON flm_cat.film_id = fil.film_id \n       LEFT JOIN inventory inv \n              ON fil.film_id = inv.film_id \n       LEFT JOIN rental ren \n              ON inv.inventory_id = ren.inventory_id \n       LEFT JOIN payment pay \n              ON ren.rental_id = pay.rental_id \nGROUP  BY cat.name \nORDER  BY revenue DESC \nLIMIT  5; \n```\n\n## Opening SQLite Databases Directly\n\nSQLite databases can also be opened directly and can be used transparently instead of a DuckDB database file. In any client, when connecting, a path to a SQLite database file can be provided and the SQLite database will be opened instead.\n\nFor example, with the shell:\n\n```sql\n$ \u003e duckdb data/db/sakila.db \nv0.9.1 401c8061c6\nD SHOW tables;\n┌────────────────────────┐\n│          name          │\n│        varchar         │\n├────────────────────────┤\n│ actor                  │\n│ address                │\n│ category               │\n│ city                   │\n│ country                │\n│ customer               │\n│ customer_list          │\n│ film                   │\n│ film_actor             │\n│ film_category          │\n│ film_list              │\n│ film_text              │\n│ inventory              │\n│ language               │\n│ payment                │\n│ rental                 │\n│ sales_by_film_category │\n│ sales_by_store         │\n│ staff                  │\n│ staff_list             │\n│ store                  │\n├────────────────────────┤\n│        21 rows         │\n└────────────────────────┘\n```\n\n## Writing Data to SQLite\n\nIn addition to reading data from SQLite, the extension also allows you to create new SQLite database files, create tables, ingest data into SQLite and make other modifications to SQLite database files using standard SQL queries.\n\nThis allows you to use DuckDB to, for example, export data that is stored in a SQLite database to Parquet, or read data from a Parquet file into SQLite.\n\nBelow is a brief example of how to create a new SQLite database and load data into it.\n\n```sql\nATTACH 'new_sqlite_database.db' AS sqlite_db (TYPE SQLITE);\nCREATE TABLE sqlite_db.tbl(id INTEGER, name VARCHAR);\nINSERT INTO sqlite_db.tbl VALUES (42, 'DuckDB');\n```\n\nThe resulting SQLite database can then be read into from SQLite.\n\n```sql\n$r \u003e sqlite3 new_sqlite_database.db \nSQLite version 3.39.5 2022-10-14 20:58:05\nsqlite\u003e SELECT * FROM tbl;\nid  name  \n--  ------\n42  DuckDB\n```\n\nMany operations on SQLite tables are supported. All these operations directly modify the SQLite database, and the result of subsequent operations can then be read using SQLite.\n\nBelow is a list of supported operations.\n\n###### CREATE TABLE\n```sql\nCREATE TABLE sqlite_db.tbl(id INTEGER, name VARCHAR);\n```\n\n###### INSERT INTO\n```sql\nINSERT INTO sqlite_db.tbl VALUES (42, 'DuckDB');\n```\n\n###### SELECT\n```sql\nSELECT * FROM sqlite_db.tbl;\n┌───────┬─────────┐\n│  id   │  name   │\n│ int64 │ varchar │\n├───────┼─────────┤\n│    42 │ DuckDB  │\n└───────┴─────────┘\n```\n\n###### COPY\n```sql\nCOPY sqlite_db.tbl TO 'data.parquet';\nCOPY sqlite_db.tbl FROM 'data.parquet';\n```\n\n###### UPDATE\n```sql\nUPDATE sqlite_db.tbl SET name='Woohoo' WHERE id=42;\n```\n\n###### DELETE\n```sql\nDELETE FROM sqlite_db.tbl WHERE id=42;\n```\n\n###### ALTER TABLE\n```sql\nALTER TABLE sqlite_db.tbl ADD COLUMN k INTEGER;\n```\n\n###### DROP TABLE\n```sql\nDROP TABLE sqlite_db.tbl;\n```\n\n###### CREATE VIEW\n```sql\nCREATE VIEW sqlite_db.v1 AS SELECT 42;\n```\n\n###### Transactions\n```sql\nCREATE TABLE sqlite_db.tmp(i INTEGER);\nBEGIN;\nINSERT INTO sqlite_db.tmp VALUES (42);\nSELECT * FROM sqlite_db.tmp;\n┌───────┐\n│   i   │\n│ int64 │\n├───────┤\n│    42 │\n└───────┘\nROLLBACK;\nSELECT * FROM sqlite_db.tmp;\n┌────────┐\n│   i    │\n│ int64  │\n├────────┤\n│ 0 rows │\n└────────┘\n```\n\n## Building \u0026 Loading the Extension\n\nTo build, type \n```\nmake\n```\n\nTo run, run the bundled `duckdb` shell:\n```\n ./build/release/duckdb -unsigned\n```\n\nThen, load the SQLite extension like so:\n```SQL\nLOAD 'build/release/extension/sqlite_scanner/sqlite_scanner.duckdb_extension';\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduckdb%2Fduckdb-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduckdb%2Fduckdb-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduckdb%2Fduckdb-sqlite/lists"}