official Python connector for GetSetDB
Project description
getsetpy
Python connector for GetSetDB with official support.
Some familiarity with GetSetDB would come a long way in using getsetpy as most of the API calls by the space.Space
and database.Database
inter-actors comes directly from it. To learn GetSetDB, refer to A Tour of GetSetDB
Installation
$ pip install getsetpy
Usage
getsetpy provides an interface to GetSetDB by using inter-actors that provide a similar and easy to use API for sending commands to the Space or a particular Database.
Space API
To run Space commands, use the space.Space
inter-actor -
from getsetpy.space import Space
space = Space()
databases = space.ls() # returns list of all databases
space.new('users') # creates a new database
space.delete('old_database') # deletes an old database
space.rename('users', 'people') # renames 'user' database to 'people'
commands = space.commands() # returns a list of commands for "space"
Database API
To run commands for a specific Database, use the database.Database
inter-actor -
from getsetpy.database import Database
# connects to the 'users' database
users = Database('users')
# if it does not exist, it raises a DatabaseNotFound exception
# returns a dictionary with all the user keys as values and a redundant number as the key
users = users.all()
# returns an empty dictionary if no pairs are found
# but if the users database was populated like this -
# manan : yadav
# bruce : wayne
# martha : stewart
# kunal : pahuja
# peter : parker
# donald : trump
# barry : allen
# sheldon : cooper
# then the dictionary would look like
# {1.0: 'manan', 2.0: 'bruce', 3.0: 'martha', 4.0: 'kunal', 5.0: 'peter', 6.0: 'donald', 7.0: 'barry', 8.0: 'sheldon'}
# deletes the pair - donald : trump to database 'users'
users.delete('donald')
# gets the value for key 'barry'
users.get('barry')
# 'allen'
# adds the pair - wonder : woman to database 'users'
users.set('wonder', 'woman')
# returns a dictionary containg info about the database 'users'
# like its size in bytes and the path to its file
users.info()
# {'size': '136 bytes', 'path': '/tmp/gsdb/users.gsdb'}
# returns the number of pairs in the 'users' database
users.count()
# 8
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file getsetpy-1.2.1.tar.gz
.
File metadata
- Download URL: getsetpy-1.2.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bd191f083c7433173cb7d1d880b49a1060d8f3f3f3096f34d0a14f8e7417f08 |
|
MD5 | 279fd8e098ea4be9580f225ecc7c4506 |
|
BLAKE2b-256 | f56ef7330d0df2badd34d600174c1d2d15d607e10b104c5ea492351f5d554555 |
File details
Details for the file getsetpy-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: getsetpy-1.2.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25ac41a2d53a092278f2983399172fdbac6cc395438d7447b0870a3a989cb286 |
|
MD5 | c4bd199724cba36f994d75b1547afb2c |
|
BLAKE2b-256 | b71c2c95ff199d4e357403c21c43dce8bb4b671b07b17b6d9119421ab1ed460d |