Skip to main content

A very fast in-memory database with export to sqlite written purely in python

Project description

pymemdb

CircleCI codecov

will soon be available with

pip install pymemdb

Description

Very simple RDMBS that is supposed to serve as a drop-in replacement for a conventional DB during build-up. It is very fast, completely written in python und relies heavily on dictionaries. It features a to_sqlite export method - more DBs will follow.

Usage

Insert into a table

from pymemdb import Table

table = Table()
row1 = dict(firstname="John", lastname="Smith")
row2 = dict(firstname="Jane", lastname="Smith")
row3 = dict(firstname="John", lastname="Doe")

for row in [row1, row2, row3]:
    table.insert(row)

iterate over the entire table

print(list(table.all()))

[{'id': 0, 'firstname': 'John', 'lastname': 'Smith'},
 {'id': 1, 'firstname': 'Jane', 'lastname': 'Smith'},
 {'id': 2, 'firstname': 'John', 'lastname': 'Doe'}]

update rows

table.update(where={"firstname": "Jane"}, firstname="Joanne")
print(list(table.all()))

[{'id': 0, 'firstname': 'John', 'lastname': 'Smith'},
 {'id': 1, 'firstname': 'Joanne', 'lastname': 'Smith'},
 {'id': 2, 'firstname': 'John', 'lastname': 'Doe'}]

search for rows

print(list(table.find(firstname="John")))

[{'id': 0, 'firstname': 'John', 'lastname': 'Smith'},
{'id': 2, 'firstname': 'John', 'lastname': 'Doe'}]

search for values in iterable

print(list(table.find(firstname=["John", "Joanne"])))

[{'id': 0, 'firstname': 'John', 'lastname': 'Smith'},
{'id': 1, 'firstname': 'Joanne', 'lastname': 'Smith'},
{'id': 2, 'firstname': 'John', 'lastname': 'Doe'}]

delete rows

table.delete(firstname="John", lastname="Smith")
print(list(table.all()))

[{'id': 1, 'firstname': 'Joanne', 'lastname': 'Smith'},
 {'id': 2, 'firstname': 'John', 'lastname': 'Doe'}]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymemdb-1.4.3.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

pymemdb-1.4.3-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pymemdb-1.4.3.tar.gz.

File metadata

  • Download URL: pymemdb-1.4.3.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for pymemdb-1.4.3.tar.gz
Algorithm Hash digest
SHA256 5320351d3a2da16cc7f7b27a0844bdbbbae0ea40f7bbe57a108528ce49d93b80
MD5 f2a9684a7128805fe8009b6e5d0c85a6
BLAKE2b-256 253758f2d772c1958eddedca136bd88fa2795bea71eb87ba2f9d741b774de3a1

See more details on using hashes here.

File details

Details for the file pymemdb-1.4.3-py3-none-any.whl.

File metadata

  • Download URL: pymemdb-1.4.3-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for pymemdb-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 df7e8b17cea4291624109e884f624b04e909f0bd33b9397c2fceac35c89dce53
MD5 f21cf81f0a27671cfb151ca26d60b366
BLAKE2b-256 105241a9100f0d55a21eacfcfc10c5d00c29e58e94c4996e41cc43bdd4098fb4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page