Skip to main content

A relatively simple multilayered database built on top of standard file systems.

Project description

filesystem-database

This database is easy to set up: Just make an empty folder and initialize a dbNode object in it! The database structure consists of dbNode objects. dbNodes contain more dbNodes and keys, which store a byte value.

Usage

To initalize a database:

import filesystem_database as fs_db

rootNode = fs_db.dbNode('/path/to/database/directory')

The directory passed to dbNode() must either be empty or contain only data from a dbNode.

To use keys:

rootNode.mkKey(0, 'exampleKey')     # Create a key with ID 0 and name `exampleKey`
rootNode.set(0, b'test data :D')    # Set a value to key 0
rootNode.get(0)     # Get the value of key 0 (returns `b'test data :D'` in this case)
rootNode.keys       # A list containing key IDs
rootNode.keyNames   # A dictionary containing key names and the key IDs they correspond to

Here 0 is the ID to give the key and 'exampleNode' is the optional name to assign to the key. Neither the ID nor the name may be used for multiple keys. get and set will accept either an integer for a key ID or a string for a key name.

To use nodes:

subNode = rootNode.mkNode(0, 'exampleNode') # Create a node (ID 0, name 'exampleNode') under `rootNode`
rootNode.node(0)    # Get node 0 from `rootNode`
rootNode.nodes      # A list containing node IDs
rootNode.nodeNames  # A dictionary containing node names and the node IDs they correspond to

subNode is a dbNode object whose contents are within rootNode. Here 0 is the ID to give the node (must not be taken) and 'exampleNode' is the optional name to assign to the node. Neither the ID nor the name may be used for multiple nodes. get and set will accept either an integer for a key ID or a string for a key name.

Command Line Utility

There is an included command line utility for easier management of databases. To run it, enter the following in a Python terminal:

>>> from filesystem_database import cli
>>> cli()

Commands

  1. load
  2. unload
  3. mk-key
  4. rm-key
  5. keys
  6. get
  7. set
  8. mk-node
  9. rm-node
  10. nodes
  11. node
  12. drop-node
  13. quit

Most of these are identical to the methods of a dbNode, except for a few. load and unload will load a dbNode from the supplied path. node 'enters' a node within the current node, setting it in the promp string. drop-node drops the current node and moves to its parent node. quit exits the CLI interface.

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

filesystem-database-1.0.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filesystem_database-1.0.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file filesystem-database-1.0.4.tar.gz.

File metadata

  • Download URL: filesystem-database-1.0.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for filesystem-database-1.0.4.tar.gz
Algorithm Hash digest
SHA256 694d6521ea732ec47001c4ac5537fa77cf94561a7bf254020d35117719817197
MD5 6580c08a808fef4f3b7420581a0e22ef
BLAKE2b-256 605a4ffcdb62e74b41b2ef38c95d199f6c5ec5e204c3b33015048239e817d4ae

See more details on using hashes here.

File details

Details for the file filesystem_database-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: filesystem_database-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for filesystem_database-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7e728f92ba5acfa230f74cf2bf4885d1a312fc7fdc90ef086791911176bbfb13
MD5 fea8f395a7e5b774b81ad886e8923f8f
BLAKE2b-256 1d90e5c237e61cc16f69f52e55b8a5a5a51852802a71657cd7581478b7bae836

See more details on using hashes here.

Supported by

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