{"id":13463052,"url":"https://github.com/sparklemotion/sqlite3-ruby","last_synced_at":"2026-02-28T20:04:55.123Z","repository":{"id":411078,"uuid":"30272","full_name":"sparklemotion/sqlite3-ruby","owner":"sparklemotion","description":"Ruby bindings for the SQLite3 embedded database","archived":false,"fork":false,"pushed_at":"2025-04-20T14:22:32.000Z","size":1681,"stargazers_count":802,"open_issues_count":21,"forks_count":204,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-04-23T17:12:45.900Z","etag":null,"topics":["ruby","sqlite"],"latest_commit_sha":null,"homepage":"https://sparklemotion.github.io/sqlite3-ruby/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sparklemotion.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2008-07-01T13:03:27.000Z","updated_at":"2025-04-20T14:22:35.000Z","dependencies_parsed_at":"2024-02-07T16:29:14.319Z","dependency_job_id":"ed9a0de3-463f-40c4-9ada-332df9eed0d5","html_url":"https://github.com/sparklemotion/sqlite3-ruby","commit_stats":{"total_commits":1069,"total_committers":82,"mean_commits":"13.036585365853659","dds":0.7362020579981291,"last_synced_commit":"a6c67ac28f84c23a6a986add88afac3e1a4ecc1b"},"previous_names":["luislavena/sqlite3-ruby"],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparklemotion%2Fsqlite3-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparklemotion%2Fsqlite3-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparklemotion%2Fsqlite3-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparklemotion%2Fsqlite3-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparklemotion","download_url":"https://codeload.github.com/sparklemotion/sqlite3-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477810,"owners_count":21437049,"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":["ruby","sqlite"],"created_at":"2024-07-31T13:00:45.053Z","updated_at":"2025-12-28T03:32:09.748Z","avatar_url":"https://github.com/sparklemotion.png","language":"Ruby","readme":"# Ruby Interface for SQLite3\n\n## Overview\n\nThis library allows Ruby programs to use the SQLite3 database engine (http://www.sqlite.org).\n\nNote that this module is only compatible with SQLite 3.6.16 or newer.\n\n* Source code: https://github.com/sparklemotion/sqlite3-ruby\n* Mailing list: http://groups.google.com/group/sqlite3-ruby\n* Download: http://rubygems.org/gems/sqlite3\n* Documentation: https://sparklemotion.github.io/sqlite3-ruby/\n\n[![Test suite](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/sparklemotion/sqlite3-ruby/actions/workflows/ci.yml)\n\n\n## Quick start\n\nFor help understanding the SQLite3 Ruby API, please read the [FAQ](./FAQ.md) and the [full API documentation](https://sparklemotion.github.io/sqlite3-ruby/).\n\nA few key classes whose APIs are often-used are:\n\n- SQLite3::Database ([rdoc](https://sparklemotion.github.io/sqlite3-ruby/SQLite3/Database.html))\n- SQLite3::Statement ([rdoc](https://sparklemotion.github.io/sqlite3-ruby/SQLite3/Statement.html))\n- SQLite3::ResultSet ([rdoc](https://sparklemotion.github.io/sqlite3-ruby/SQLite3/ResultSet.html))\n\nIf you have any questions that you feel should be addressed in the FAQ, please send them to [the mailing list](http://groups.google.com/group/sqlite3-ruby) or open a [discussion thread](https://github.com/sparklemotion/sqlite3-ruby/discussions/categories/q-a).\n\n\n``` ruby\nrequire \"sqlite3\"\n\n# Open a database\ndb = SQLite3::Database.new \"test.db\"\n\n# Create a table\nrows = db.execute \u003c\u003c-SQL\n  create table numbers (\n    name varchar(30),\n    val int\n  );\nSQL\n\n# Execute a few inserts\n{\n  \"one\" =\u003e 1,\n  \"two\" =\u003e 2,\n}.each do |pair|\n  db.execute \"insert into numbers values ( ?, ? )\", pair\nend\n\n# Find a few rows\ndb.execute( \"select * from numbers\" ) do |row|\n  p row\nend\n# =\u003e [\"one\", 1]\n#    [\"two\", 2]\n\n# Create another table with multiple columns\ndb.execute \u003c\u003c-SQL\n  create table students (\n    name varchar(50),\n    email varchar(50),\n    grade varchar(5),\n    blog varchar(50)\n  );\nSQL\n\n# Execute inserts with parameter markers\ndb.execute(\"INSERT INTO students (name, email, grade, blog)\n            VALUES (?, ?, ?, ?)\", [\"Jane\", \"me@janedoe.com\", \"A\", \"http://blog.janedoe.com\"])\n\ndb.execute( \"select * from students\" ) do |row|\n  p row\nend\n# =\u003e [\"Jane\", \"me@janedoe.com\", \"A\", \"http://blog.janedoe.com\"]\n```\n\n## Thread Safety\n\nWhen `SQLite3.threadsafe?` returns `true`, then SQLite3 has been compiled to\nsupport running in a multithreaded environment.  However, this doesn't mean\nthat all classes in the SQLite3 gem can be considered \"thread safe\".\n\nWhen `SQLite3.threadsafe?` returns `true`, it is safe to share only\n`SQLite3::Database` instances among threads without providing your own locking\nmechanism.  For example, the following code is fine because only the database\ninstance is shared among threads:\n\n```ruby\nrequire 'sqlite3'\n\ndb = SQLite3::Database.new \":memory:\"\n\nlatch = Queue.new\n\nts = 10.times.map {\n  Thread.new {\n    latch.pop\n    db.execute \"SELECT '#{Thread.current.inspect}'\"\n  }\n}\n10.times { latch \u003c\u003c nil }\n\np ts.map(\u0026:value)\n```\n\nOther instances can be shared among threads, but they require that you provide\nyour own locking for thread safety.  For example, `SQLite3::Statement` objects\n(prepared statements) are mutable, so applications must take care to add\nappropriate locks to avoid data race conditions when sharing these objects\namong threads.\n\nLets rewrite the above example but use a prepared statement and safely share\nthe prepared statement among threads:\n\n```ruby\ndb = SQLite3::Database.new \":memory:\"\n\n# Prepare a statement\nstmt = db.prepare \"SELECT :inspect\"\nstmt_lock = Mutex.new\n\nlatch = Queue.new\n\nts = 10.times.map {\n  Thread.new {\n    latch.pop\n\n    # Add a lock when using the prepared statement.\n    # Binding values, and walking over results will mutate the statement, so\n    # in order to prevent other threads from \"seeing\" this thread's data, we\n    # must lock when using the statement object\n    stmt_lock.synchronize do\n      stmt.execute(Thread.current.inspect).to_a\n    end\n  }\n}\n\n10.times { latch \u003c\u003c nil }\n\np ts.map(\u0026:value)\n\nstmt.close\n```\n\nIt is generally recommended that if applications want to share a database among\nthreads, they _only_ share the database instance object.  Other objects are\nfine to share, but may require manual locking for thread safety.\n\n\n## Fork Safety\n\n[Sqlite is not fork\nsafe](https://www.sqlite.org/howtocorrupt.html#_carrying_an_open_database_connection_across_a_fork_)\nand instructs users to not carry an open writable database connection across a `fork()`. Using an inherited\nconnection in the child may corrupt your database, leak memory, or cause other undefined behavior.\n\nTo help protect users of this gem from accidental corruption due to this lack of fork safety, the gem will immediately close any open writable databases in the child after a fork. Discarding writable\nconnections in the child will incur a small one-time memory leak per connection, but that's\npreferable to potentially corrupting your database.\n\nWhenever possible, close writable connections in the parent before forking. If absolutely necessary (and you know what you're doing), you may suppress the fork safety warnings by calling `SQLite3::ForkSafety.suppress_warnings!`.\n\nSee [./adr/2024-09-fork-safety.md](./adr/2024-09-fork-safety.md) for more information and context.\n\n\n## Support\n\n### Installation or database extensions\n\nIf you're having trouble with installation, please first read [`INSTALLATION.md`](./INSTALLATION.md).\n\n### General help requests\n\nYou can ask for help or support:\n\n* by emailing the [sqlite3-ruby mailing list](http://groups.google.com/group/sqlite3-ruby)\n* by opening a [discussion thread](https://github.com/sparklemotion/sqlite3-ruby/discussions/categories/q-a) on Github\n\n### Bug reports\n\nYou can file the bug at the [github issues page](https://github.com/sparklemotion/sqlite3-ruby/issues).\n\n\n## Contributing\n\nSee [`CONTRIBUTING.md`](./CONTRIBUTING.md).\n\n\n## License\n\nThis library is licensed under `BSD-3-Clause`, see [`LICENSE`](./LICENSE).\n\n### Dependencies\n\nThe source code of `sqlite` is distributed in the \"ruby platform\" gem. This code is public domain,\nsee https://www.sqlite.org/copyright.html for details.\n","funding_links":[],"categories":["Data Persistence","Database Drivers","Ruby","Language Bindings"],"sub_categories":["SQL Database Adapters"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparklemotion%2Fsqlite3-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparklemotion%2Fsqlite3-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparklemotion%2Fsqlite3-ruby/lists"}