{"id":13725558,"url":"https://github.com/piskvorky/sqlitedict","last_synced_at":"2026-04-20T22:01:16.778Z","repository":{"id":1583348,"uuid":"2072368","full_name":"piskvorky/sqlitedict","owner":"piskvorky","description":"Persistent dict, backed by sqlite3 and pickle, multithread-safe.","archived":false,"fork":false,"pushed_at":"2022-12-07T16:37:05.000Z","size":253,"stargazers_count":1245,"open_issues_count":38,"forks_count":137,"subscribers_count":28,"default_branch":"master","last_synced_at":"2026-04-16T12:06:25.898Z","etag":null,"topics":["data-store","multi-threading","python","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piskvorky.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","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":"2011-07-19T14:09:09.000Z","updated_at":"2026-04-16T10:58:39.000Z","dependencies_parsed_at":"2022-06-25T17:35:51.514Z","dependency_job_id":null,"html_url":"https://github.com/piskvorky/sqlitedict","commit_stats":null,"previous_names":["piskvorky/sqlitedict","rare-technologies/sqlitedict"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/piskvorky/sqlitedict","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piskvorky%2Fsqlitedict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piskvorky%2Fsqlitedict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piskvorky%2Fsqlitedict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piskvorky%2Fsqlitedict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piskvorky","download_url":"https://codeload.github.com/piskvorky/sqlitedict/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piskvorky%2Fsqlitedict/sbom","scorecard":{"id":117041,"data":{"date":"2025-08-11","repo":{"name":"github.com/piskvorky/sqlitedict","commit":"96e81621fd6ab094efdd86e70fd57efe9d40ca12"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Code-Review","score":4,"reason":"Found 6/13 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/python-package.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/piskvorky/sqlitedict/python-package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/piskvorky/sqlitedict/python-package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/piskvorky/sqlitedict/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/piskvorky/sqlitedict/release.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:23","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:30","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:33","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 24 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T01:35:59.788Z","repository_id":1583348,"created_at":"2025-08-16T01:35:59.788Z","updated_at":"2025-08-16T01:35:59.788Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32018777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":["data-store","multi-threading","python","sqlite"],"created_at":"2024-08-03T01:02:27.268Z","updated_at":"2026-04-20T22:01:16.727Z","avatar_url":"https://github.com/piskvorky.png","language":"Python","readme":"===================================================\nsqlitedict -- persistent ``dict``, backed by SQLite\n===================================================\n\n|GithubActions|_\n|License|_\n\n.. |GithubActions| image:: https://github.com/RaRe-Technologies/sqlitedict/actions/workflows/python-package.yml/badge.svg\n.. |Downloads| image:: https://img.shields.io/pypi/dm/sqlitedict.svg\n.. |License| image:: https://img.shields.io/pypi/l/sqlitedict.svg\n.. _GithubActions: https://github.com/RaRe-Technologies/sqlitedict/actions/workflows/python-package.yml\n.. _Downloads: https://pypi.python.org/pypi/sqlitedict\n.. _License: https://pypi.python.org/pypi/sqlitedict\n\nA lightweight wrapper around Python's sqlite3 database with a simple, Pythonic\ndict-like interface and support for multi-thread access:\n\nUsage\n=====\n\nWrite\n-----\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from sqlitedict import SqliteDict\n    \u003e\u003e\u003e db = SqliteDict(\"example.sqlite\")\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e db[\"1\"] = {\"name\": \"first item\"}\n    \u003e\u003e\u003e db[\"2\"] = {\"name\": \"second item\"}\n    \u003e\u003e\u003e db[\"3\"] = {\"name\": \"yet another item\"}\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # Commit to save the objects.\n    \u003e\u003e\u003e db.commit()\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e db[\"4\"] = {\"name\": \"yet another item\"}\n    \u003e\u003e\u003e # Oops, forgot to commit here, that object will never be saved.\n    \u003e\u003e\u003e # Always remember to commit, or enable autocommit with SqliteDict(\"example.sqlite\", autocommit=True)\n    \u003e\u003e\u003e # Autocommit is off by default for performance.\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e db.close()\n\nRead\n----\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from sqlitedict import SqliteDict\n    \u003e\u003e\u003e db = SqliteDict(\"example.sqlite\")\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e print(\"There are %d items in the database\" % len(db))\n    There are 3 items in the database\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # Standard dict interface. items() values() keys() etc...\n    \u003e\u003e\u003e for key, item in db.items():\n    ...     print(\"%s=%s\" % (key, item))\n    1={'name': 'first item'}\n    2={'name': 'second item'}\n    3={'name': 'yet another item'}\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e db.close()\n\nEfficiency\n----------\n\nBy default, sqlitedict's exception handling favors verbosity over efficiency.\nIt extracts and outputs the outer exception stack to the error logs.\nIf you favor efficiency, then initialize the DB with outer_stack=False.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from sqlitedict import SqliteDict\n    \u003e\u003e\u003e db = SqliteDict(\"example.sqlite\", outer_stack=False)  # True is the default\n    \u003e\u003e\u003e db[1]\n    {'name': 'first item'}\n\nContext Manager\n---------------\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from sqlitedict import SqliteDict\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # The database is automatically closed when leaving the with section.\n    \u003e\u003e\u003e # Uncommitted objects are not saved on close. REMEMBER TO COMMIT!\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e with SqliteDict(\"example.sqlite\") as db:\n    ...     print(\"There are %d items in the database\" % len(db))\n    There are 3 items in the database\n\nTables\n------\n\nA database file can store multiple tables.\nA default table is used when no table name is specified.\n\nNote: Writes are serialized, having multiple tables does not improve performance.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from sqlitedict import SqliteDict\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e products = SqliteDict(\"example.sqlite\", tablename=\"product\", autocommit=True)\n    \u003e\u003e\u003e manufacturers = SqliteDict(\"example.sqlite\", tablename=\"manufacturer\", autocommit=True)\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e products[\"1\"] = {\"name\": \"first item\",  \"manufacturer_id\": \"1\"}\n    \u003e\u003e\u003e products[\"2\"] = {\"name\": \"second item\", \"manufacturer_id\": \"1\"}\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e manufacturers[\"1\"] = {\"manufacturer_name\": \"afactory\", \"location\": \"US\"}\n    \u003e\u003e\u003e manufacturers[\"2\"] = {\"manufacturer_name\": \"anotherfactory\", \"location\": \"UK\"}\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e tables = products.get_tablenames('example.sqlite')\n    \u003e\u003e\u003e print(tables)\n    ['unnamed', 'product', 'manufacturer']\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e products.close()\n    \u003e\u003e\u003e manufacturers.close()\n\nIn case you're wondering, the unnamed table comes from the previous examples,\nwhere we did not specify a table name.\n\nSerialization\n-------------\n\nKeys are strings. Values are any serializeable object.\n\nBy default Pickle is used internally to (de)serialize the values.\n\nIt's possible to use a custom (de)serializer, notably for JSON and for compression.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e # Use JSON instead of pickle\n    \u003e\u003e\u003e import json\n    \u003e\u003e\u003e with SqliteDict(\"example.sqlite\", encode=json.dumps, decode=json.loads) as mydict:\n    ...     pass\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e # Apply zlib compression after pickling\n    \u003e\u003e\u003e import zlib, pickle, sqlite3\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e def my_encode(obj):\n    ...     return sqlite3.Binary(zlib.compress(pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)))\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e def my_decode(obj):\n    ...     return pickle.loads(zlib.decompress(bytes(obj)))\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e with SqliteDict(\"example.sqlite\", encode=my_encode, decode=my_decode) as mydict:\n    ...     pass\n\nIt's also possible to use a custom (de)serializer for keys to allow non-string keys.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e # Use key encoding instead of default string keys only\n    \u003e\u003e\u003e from sqlitedict import encode_key, decode_key\n    \u003e\u003e\u003e with SqliteDict(\"example.sqlite\", encode_key=encode_key, decode_key=decode_key) as mydict:\n    ...     pass\n\nMore\n----\n\nFunctions are well documented, see docstrings directly in ``sqlitedict.py`` or call ``help(sqlitedict)``.\n\n**Beware**: because of Python semantics, ``sqlitedict`` cannot know when a mutable\nSqliteDict-backed entry was modified in RAM. You'll need to\nexplicitly assign the mutated object back to SqliteDict:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from sqlitedict import SqliteDict\n    \u003e\u003e\u003e db = SqliteDict(\"example.sqlite\")\n    \u003e\u003e\u003e db[\"colors\"] = {\"red\": (255, 0, 0)}\n    \u003e\u003e\u003e db.commit()\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e colors = db[\"colors\"]\n    \u003e\u003e\u003e colors[\"blue\"] = (0, 0, 255) # sqlite DB not updated here!\n    \u003e\u003e\u003e db[\"colors\"] = colors  # now updated\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e db.commit() # remember to commit (or set autocommit)\n    \u003e\u003e\u003e db.close()\n\nFeatures\n========\n\n* Values can be **any picklable objects** (uses ``pickle`` with the highest protocol).\n* Support for **multiple tables** (=dicts) living in the same database file.\n* Support for **access from multiple threads** to the same connection (needed by e.g. Pyro).\n  Vanilla sqlite3 gives you ``ProgrammingError: SQLite objects created in a thread can\n  only be used in that same thread.``\n\n  Concurrent requests are still serialized internally, so this \"multithreaded support\"\n  **doesn't** give you any performance benefits. It is a work-around for sqlite limitations in Python.\n\n* Support for **custom serialization or compression**:\n\n.. code-block:: python\n\n  # use JSON instead of pickle\n  \u003e\u003e\u003e import json\n  \u003e\u003e\u003e mydict = SqliteDict('./my_db.sqlite', encode=json.dumps, decode=json.loads)\n\n  # apply zlib compression after pickling\n  \u003e\u003e\u003e import zlib, pickle, sqlite3\n  \u003e\u003e\u003e def my_encode(obj):\n  ...     return sqlite3.Binary(zlib.compress(pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)))\n  \u003e\u003e\u003e def my_decode(obj):\n  ...     return pickle.loads(zlib.decompress(bytes(obj)))\n  \u003e\u003e\u003e mydict = SqliteDict('./my_db.sqlite', encode=my_encode, decode=my_decode)\n\n* sqlite is efficient and can work effectively with large databases (multi gigabytes), not limited by memory.\n* sqlitedict is mostly a thin wrapper around sqlite.\n* ``items()`` ``keys()`` ``values()`` are iterating one by one, the rows are loaded in a worker thread and queued in memory.\n* ``len()`` is calling sqlite to count rows, that is scanning the whole table.\n* For better performance, write objects in batch and ``commit()`` once.\n\nInstallation\n============\n\nThe module has no dependencies beyond Python itself.\nThe minimum supported Python version is 3.7, continuously tested on Python 3.7, 3.8, 3.9, and 3.10 `on Travis \u003chttps://travis-ci.org/RaRe-Technologies/sqlitedict\u003e`_.\n\nInstall or upgrade with::\n\n    pip install -U sqlitedict\n\nor from the `source tar.gz \u003chttp://pypi.python.org/pypi/sqlitedict\u003e`_::\n\n    python setup.py install\n\nContributions\n=============\n\nTesting\n-------\n\nInstall::\n\n    $ pip install pytest coverage pytest-coverage\n\nTo perform all tests::\n\n    $ mkdir -p tests/db\n    $ pytest tests\n    $ python -m doctest README.rst\n\nTo perform all tests with coverage::\n\n    $ pytest tests --cov=sqlitedict\n\nComments, bug reports\n---------------------\n\n``sqlitedict`` resides on `github \u003chttps://github.com/RaRe-Technologies/sqlitedict\u003e`_. You can file\nissues or pull requests there.\n\nLicense\n=======\n\n``sqlitedict`` is open source software released under the `Apache 2.0 license \u003chttp://opensource.org/licenses/apache2.0.php\u003e`_.\nCopyright (c) 2011-now `Radim Řehůřek \u003chttp://radimrehurek.com\u003e`_ and contributors.\n\nHousekeeping\n============\n\nClean up the test database to keep each doctest run idempotent:\n\n.. code-block:: python\n\n   \u003e\u003e\u003e import os\n   \u003e\u003e\u003e if __name__ == '__main__':\n   ...     os.unlink('example.sqlite')\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiskvorky%2Fsqlitedict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiskvorky%2Fsqlitedict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiskvorky%2Fsqlitedict/lists"}