{"id":13500083,"url":"https://github.com/coleifer/vedis-python","last_synced_at":"2025-04-06T19:32:12.265Z","repository":{"id":17861202,"uuid":"20789396","full_name":"coleifer/vedis-python","owner":"coleifer","description":"Python bindings for the Vedis embedded NoSQL database","archived":false,"fork":false,"pushed_at":"2024-02-08T15:40:18.000Z","size":683,"stargazers_count":126,"open_issues_count":0,"forks_count":10,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T16:44:40.310Z","etag":null,"topics":["cython","embedded-database","nosql","python","vedis"],"latest_commit_sha":null,"homepage":"http://vedis-python.readthedocs.org/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coleifer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2014-06-13T02:16:26.000Z","updated_at":"2024-12-05T16:01:26.000Z","dependencies_parsed_at":"2024-10-31T18:31:45.672Z","dependency_job_id":"478c280a-af70-4c2c-87b9-7269b56ce052","html_url":"https://github.com/coleifer/vedis-python","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fvedis-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fvedis-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fvedis-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coleifer%2Fvedis-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coleifer","download_url":"https://codeload.github.com/coleifer/vedis-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247539248,"owners_count":20955278,"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":["cython","embedded-database","nosql","python","vedis"],"created_at":"2024-07-31T22:00:51.010Z","updated_at":"2025-04-06T19:32:11.613Z","avatar_url":"https://github.com/coleifer.png","language":"C","readme":"### WARNING:\n\n[Vedis](https://github.com/symisc/vedis) appears to be no longer maintained by symisc.\n\n![](http://media.charlesleifer.com/blog/photos/vedis-python-logo.png)\n\nFast Python bindings for the Vedis embedded NoSQL database. Vedis is a fun, fast, embedded database modeled after Redis.\n\n[View the vedis-python documentation](https://vedis-python.readthedocs.io/).\n\n### Features\n\nVedis features:\n\n* Embedded, zero-conf database\n* Transactional (ACID)\n* Single file or in-memory database\n* Key/value store\n* [Over 70 commands](http://vedis.symisc.net/commands.html) similar to standard [Redis](http://redis.io) commands.\n* Thread-safe\n* Terabyte-sized databases\n\nVedis-Python features:\n\n* Compiled library, extremely fast with minimal overhead.\n* Supports key/value operations and transactions using Pythonic APIs.\n* Support for executing Vedis commands.\n* Write custom commands in Python.\n* Python 2.x and 3.x.\n\nLimitations:\n\n* Not tested on Windoze.\n\nThe previous version (0.2.0) of `vedis-python` utilized `ctypes` to wrap the Vedis C library. By switching to Cython, key/value and Vedis command operations are significantly faster.\n\nLinks:\n\n* [vedis-python documentation](https://vedis-python.readthedocs.io/)\n* [Vedis's C API](http://vedis.symisc.net/c_api.html)\n\nIf you like Vedis, you might also want to check out [UnQLite](http://unqlite.symisc.net), an embedded key/value database with cursors and a cool JSON document store (python bindings: [unqlite-python](https://unqlite-python.readthedocs.io)).\n\n## Installation\n\nYou can install vedis-python using `pip`.\n\n    pip install vedis\n\nBasic usage\n-----------\n\nFirst you instantiate a `Vedis` object, passing in either the path to the database\nfile or the special string `':mem:'` for an in-memory database.\n\nBelow is a sample interactive console session designed to show some of the basic features and functionality of the vedis-python library. Also check out the [full API documentation](https://vedis-python.readthedocs.io/en/latest/api.html) as well as the [vedis command documentation](http://vedis.symisc.net/commands.html).\n\n### Key/value features\n\nYou can use Vedis like a dictionary for simple key/value lookups:\n\n```python\n\n\u003e\u003e\u003e from vedis import Vedis\n\u003e\u003e\u003e db = Vedis(':mem:')  # Create an in-memory database. Alternatively you could supply a filename for an on-disk database.\n\u003e\u003e\u003e db['k1'] = 'v1'\n\u003e\u003e\u003e db['k1']\n'v1'\n\n\u003e\u003e\u003e db.append('k1', 'more data')  # Returns length of value after appending new data.\n11\n\u003e\u003e\u003e db['k1']\n'v1more data'\n\n\u003e\u003e\u003e del db['k1']\n\u003e\u003e\u003e 'k1' in db\nFalse\n\u003e\u003e\u003e db['k1']\nNone\n```\n\nYou can set and get multiple items at a time:\n\n```python\n\n\u003e\u003e\u003e db.mset(dict(k1='v1', k2='v2', k3='v3'))\nTrue\n\n\u003e\u003e\u003e db.mget(['k1', 'k2', 'missing key', 'k3'])\n['v1', 'v2', None, 'v3']\n```\n\nIn addition to storing string keys/values, you can also implement counters:\n\n```python\n\n\u003e\u003e\u003e db.incr('counter')\n1\n\u003e\u003e\u003e db.incr('counter')\n2\n\n\u003e\u003e\u003e db.incr_by('counter', 10)\n12\n\u003e\u003e\u003e db.decr('counter')\n11\n```\n\n### Hashes\n\nVedis supports nested key/value lookups which have the additional benefit of supporting operations to retrieve all keys, values, the number of items in the hash, and so on.\n\n```python\n\n\u003e\u003e\u003e h = db.Hash('some key')\n\u003e\u003e\u003e h['k1'] = 'v1'\n\u003e\u003e\u003e h.update(k2='v2', k3='v3')\n\n\u003e\u003e\u003e h\n\u003cHash: {'k3': 'v3', 'k2': 'v2', 'k1': 'v1'}\u003e\n\n\u003e\u003e\u003e h.to_dict()\n{'k3': 'v3', 'k2': 'v2', 'k1': 'v1'}\n\n\u003e\u003e\u003e h.items()\n[('k1', 'v1'), ('k3', 'v3'), ('k2', 'v2')]\n\n\u003e\u003e\u003e h.keys()\n['k1', 'k3', 'k2']\n\n\u003e\u003e\u003e del h['k2']\n\n\u003e\u003e\u003e len(h)\n2\n\n\u003e\u003e\u003e 'k1' in h\nTrue\n\n\u003e\u003e\u003e [key for key in h]\n['k1', 'k3']\n```\n\n### Sets\n\nVedis supports a set data-type which stores a unique collection of items.\n\n```python\n\n\u003e\u003e\u003e s = db.Set('some set')\n\u003e\u003e\u003e s.add('v1', 'v2', 'v3')\n3\n\n\u003e\u003e\u003e len(s)\n3\n\n\u003e\u003e\u003e 'v1' in s, 'v4' in s\n(True, False)\n\n\u003e\u003e\u003e s.top()\n'v1'\n\n\u003e\u003e\u003e s.peek()\n'v3'\n\n\u003e\u003e\u003e del s['v2']\n1\n\n\u003e\u003e\u003e s.add('v4', 'v5')\n2\n\n\u003e\u003e\u003e s.pop()\n'v5'\n\n\u003e\u003e\u003e [item for item in s]\n['v1', 'v3', 'v4']\n\n\u003e\u003e\u003e s.to_set()\nset(['v1', 'v3', 'v4'])\n\n\u003e\u003e\u003e s2 = db.Set('another set')\n\u003e\u003e\u003e s2.add('v1', 'v4', 'v5', 'v6')\n4\n\n\u003e\u003e\u003e s2 \u0026 s  # Intersection.\nset(['v1', 'v4'])\n\n\u003e\u003e\u003e s2 - s  # Difference.\nset(['v5', 'v6'])\n```\n\n### Lists\n\nVedis also supports a list data type.\n\n```python\n\n\u003e\u003e\u003e l = db.List('my list')\n\u003e\u003e\u003e l.append('v1')\n1\n\u003e\u003e\u003e l.extend(['v2', 'v3', 'v4'])\n4\n\n\u003e\u003e\u003e len(l)\n4\n\n\u003e\u003e\u003e l[1]\n'v2'\n\n\u003e\u003e\u003e l.pop(), l.pop()\n('v1', 'v2')\n\n\u003e\u003e\u003e len(l)\n2\n```\n\n### Misc\n\nVedis has a somewhat quirky collection of other miscellaneous commands. Below is a sampling:\n\n```python\n\n\u003e\u003e\u003e db.base64('encode me')\n'ZW5jb2RlIG1l'\n\n\u003e\u003e\u003e db.base64_decode('ZW5jb2RlIG1l')\n'encode me'\n\n\u003e\u003e\u003e db.random_string(10)\n'raurquvsnx'\n\n\u003e\u003e\u003e db.rand(1, 6)\n4\n\n\u003e\u003e\u003e db.str_split('abcdefghijklmnop', 5)\n['abcde', 'fghij', 'klmno', 'p']\n\n\u003e\u003e\u003e db['data'] = 'abcdefghijklmnop'\n\u003e\u003e\u003e db.strlen('data')\n16\n\n\u003e\u003e\u003e db.strip_tags('\u003cp\u003eThis \u003cspan\u003eis\u003c/span\u003e a \u003ca href=\"#\"\u003etest\u003c/a\u003e.\u003c/p\u003e')\n'This is a test.'\n```\n\n### Writing your own Vedis commands\n\nIt is easy to write your own Vedis commands:\n\n```python\n\ndb = Vedis()\n\n@db.register('CONCAT')\ndef concat(context, glue, *params):\n    return glue.join(params)\n\n@db.register('TITLE')\ndef title(context, *params):\n    # The `context` can be used to access the key/value store.\n    for param in params:\n        context[param] = param.title()\n    return True\n```\n\nHere is how you might call the custom commands:\n\n```python\n\n\u003e\u003e\u003e print db.execute('CONCAT | foo bar baz')\nfoo|bar|baz\n\n\u003e\u003e\u003e db.execute('TITLE \"testing\" \"this is a test\" \"another\"')\nTrue\n\u003e\u003e\u003e print db['testing']\nTesting\n\u003e\u003e\u003e print db['this is a test']\nThis Is A Test\n\n\u003e\u003e\u003e title('foo', 'bar')  # Calling the wrapped function will go through Vedis.\nTrue\n\u003e\u003e\u003e print db['foo']\nFoo\n\u003e\u003e\u003e print db['bar']\nBar\n```\n\n-------------------------------------------\n\nThis code is based in part on [buaabyl's pyUnQLite](https://github.com/buaabyl/pyUnQLite/).\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoleifer%2Fvedis-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoleifer%2Fvedis-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoleifer%2Fvedis-python/lists"}