{"id":20805760,"url":"https://github.com/danbugs/dancing_sql","last_synced_at":"2026-06-23T19:32:36.701Z","repository":{"id":47251362,"uuid":"403403630","full_name":"danbugs/dancing_sql","owner":"danbugs","description":"This is an incoming SQLite clone compiled to WebAssembly.","archived":false,"fork":false,"pushed_at":"2021-09-11T18:04:42.000Z","size":332,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T03:33:42.486Z","etag":null,"topics":["c","sql","webassembly"],"latest_commit_sha":null,"homepage":"https://danbugs.github.io/dancing_sql/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danbugs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-05T20:11:25.000Z","updated_at":"2021-09-11T18:04:45.000Z","dependencies_parsed_at":"2022-07-20T16:49:00.562Z","dependency_job_id":null,"html_url":"https://github.com/danbugs/dancing_sql","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/danbugs/dancing_sql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbugs%2Fdancing_sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbugs%2Fdancing_sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbugs%2Fdancing_sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbugs%2Fdancing_sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danbugs","download_url":"https://codeload.github.com/danbugs/dancing_sql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danbugs%2Fdancing_sql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34704743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["c","sql","webassembly"],"created_at":"2024-11-17T19:16:14.824Z","updated_at":"2026-06-23T19:32:36.684Z","avatar_url":"https://github.com/danbugs.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DanCing SQL 💃📂 (DCS)\r\n\r\nThis is an **incoming** SQLite clone compiled to WebAssembly — heavily inspired by [this](https://cstack.github.io/db_tutorial/).\r\n\r\n## Getting Started\r\n\r\nDancing SQL is now distributed with the [Tarantella Package Manager](https://github.com/danbugs/tarantella) — a tool I've made to simplify setup of projects like these!\r\n\r\nTo install the Tarantella Package Manager, you need the Rust toolchain — for instructions on how to install it, see [this](https://www.rust-lang.org/tools/install). Once you're done with that, you can install Tarantella by running: `cargo install tarantella`.\r\n\r\nTo start-off, setup a new main module WASM project with: `tapm new my-first-project --server`. This will start a new C WASM project with:\r\n\r\n- a build folder,\r\n- a dependencies folder,\r\n- an index.js,\r\n- a `Makefile`,\r\n- a releases folder,\r\n- a src folder with some starting code in `main.c`, and a\r\n- `Tarantella.toml` file.\r\n\r\nNext, add the latest version of Dancing SQL as a dependency with: `tapm add \"danbugs/dancing_sql\"`. This will automatically download DCS to your dependencies folder, add it to your `Tarantella.toml` list of dependencies, and append `dependencies/dcs/dcs.o` to the `DEPENDENCIES` variable of your `Makefile` to facilitate compilation.\r\n\r\nNow, replace the content of `src/main.c`with:\r\n\r\n```C\r\n#include \u003cstdio.h\u003e\r\n#include \u003cemscripten.h\u003e\r\n#include \"../dependencies/dcs/dcs.h\"\r\n// ^^^ adds necessary structs and definitions from DCS\r\n\r\nextern Statement execute_sql(sql_t raw_sql, Table *table);\r\nextern Table *open_table(char *table_name);\r\nextern void close_table(Table *table);\r\n// ^^^ group of functions coming from ../dependencies/dcs/dcs.o\r\n\r\nint main()\r\n{\r\n    Table *table = open_table(\"mytable\");\r\n    // ^^^ creating a new default table.\r\n    // Default Structure:\r\n    // - INTEGER id, and\r\n    // - VARCHAR(255) content ~ meant to contain all necessary info in sort of a JSON.stringify-ed way.\r\n    // Notes:\r\n    // - content will be trucated at 255 characters.\r\n    // - just like VARCHAR, you content does not\r\n    // need to have 255 bytes but; regardless,\r\n    // 255 will still be allocated for that field.\r\n\r\n    sql_t insert_s = SQL(INSERT 0 '{\"name\":\"dan\"}');\r\n    // ^^^ un-executed insert statement.\r\n    // Notes:\r\n    // - 'INSERT' must be upper-case, the VM\r\n    // is case-sensitive.\r\n    // - There are currently no checks to ensure\r\n    // the ID is unique.\r\n\r\n    sql_t select_s = SQL(SELECT);\r\n    // ^^^ un-executed select statement.\r\n    // Note: 'SELECT' must be upper-case, the VM\r\n    // is case-sensitive.\r\n\r\n    Statement insert_r = execute_sql(insert_s, table);\r\n    Statement select_r = execute_sql(select_s, table);\r\n    printf(\"select: %s\\n\", select_r.select_result);\r\n    // ^^^ executes SQL statements and\r\n    // prints results to console.\r\n\r\n    close_table(table);\r\n    // ^^^ frees malloc-ed table and its'\r\n    // attributes and saves data to database file.\r\n}\r\n```\r\n\r\nNext, in your `Makefile`, change the `EMCC_CFLAGS` to:\r\n```Makefile\r\nEMCC_CFLAGS=-s MAIN_MODULE=1 -lnodefs.js -s EXIT_RUNTIME=1\r\n```\r\n\r\nNow, to finish off, run `tapm build` to compile our code and `tapm run` to test it out. You should see the following in your console:\r\n![getting-started-result](https://i.imgur.com/SFGtWBc.png)\r\n\r\nYour information will be persisted to a file at `db/mytable.db`.\r\n\r\nYou can view the `mytable.db` file directly w/ a hex editor. In VSCode, you can install [this](https://marketplace.visualstudio.com/items?itemName=slevesque.vscode-hexdump) extension, right click the `mytable.db` file and select \"Show hexdump\". You should see:\r\n\r\n![getting-started-hexdump-of-db-file](https://i.imgur.com/QxhZhtg.png)\r\n\r\n## Notes to Self\r\n\r\nUse: `emcc .\\src\\main.c ..\\src\\dcs.c -l\"nodefs.js\" -s EXIT_RUNTIME=1 -fsanitize=address \r\n-s ALLOW_MEMORY_GROWTH -gsource-map --source-map-base http://localhost:3000/test -o \r\ntest/example.js` to check for mem-leaks and whatnot.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanbugs%2Fdancing_sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanbugs%2Fdancing_sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanbugs%2Fdancing_sql/lists"}