Skip to main content

A small document database

Project description

PicoDoc 📝

This is a document database module made for small-scale applications. Please don't use this module if your data is very important. It is not tested very extensively.

This project is on pypi and on github.

Installation

The project is up on pypi (PYthon Package Index). So installing can be done using pip.

Unix & Mac os X:

pip3 install picodoc

Windows:

pip install picodoc

⚠ Notice

The objects are not really dicts and lists. So they do not support all functions of those objects.

List supports:

  • append
  • remove
  • iterating over values
  • item assignment using index
    • del list[idx]
    • value = list[idx]
    • list[idx] = new_value

Dict supports:

  • iterating over keys
  • item assignment using key
    • del list[key]
    • value = list[key]
    • list[key] = new_value

Usage

Using the library should be very straight forward. Open a database with the picodoc.open_db function and use it as if it were a dict.

To get started import the module

import picodoc

Then open the database. (The extension doesn't really matter, but I would suggest using something lile '.db' or '.picodoc')

db = picodoc.open_db('database.picodoc')

Now just treat the db as af it were a basic (see notice) dictionary.

db['users'] = {}
db['users']['donkere.v'] = {
    'name':  'Donkere Vader',
    'descprition': 'Cool dude 😎',
}

There are two ways of printing a document.

Either print it as a dict:

print(db['users']['donkere.v'])

>>>
<Document donkere.v>
{
    'name':  'Donkere Vader',
    'descprition': 'Cool dude 😎',
}

Or print it as an object:

# this will print it as if it were a document
# <Document {document key}>
print(db['users']['donkere.v'].object_repr())

>>>
<Document donkere.v>

Tip

Use the rich module for beautiful output in the console.

Testing

Testing is done via the runtests file.

To run all the tests simply do:

python3 runtests

(If you are on windows use python in stead of python3)

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

picodoc-0.1.7.tar.gz (17.7 kB view hashes)

Uploaded Source

Built Distribution

picodoc-0.1.7-py3-none-any.whl (19.6 kB view hashes)

Uploaded Python 3

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