A private database service library.
Project description
PyDBConnect
this is simply an API implementation (wrapper) for my WebAPI PyDBConnect
How to use
Clone the PyDBConnect server repo on your server and follow the instructions Use the Pypi package to use the API implementation
Installation
pip install PyDBConnect
Documentation
Import the library
>>> from pydbconnect import connection
Establish a connection to the PyDBConnect server
>>> db = connection("localhost:7575", "project", "password")
Replace the hostname with your own hostname/ip (making sure to include the port). replace "project" with your PyDBConnect project name, and the password with your pyDBConnect password.
Check server availability
>>> db.ping_db().status_code
ping_db() method returns a Response object which you can get the status code out of. if the status code returned is 200 then the server responded properly!
Get list of collections in project
>>> db.get_collections()
Should return a list of strings representing collections in the project
Get collection data
>>> db.get_collection("collection")
Should return the documents present in the collection
Get document contents
>>> db.get_document("collection", "document_id")
Returns the contents of the document
Create document
>>> db.create_document("collection", "document_id", {"key": "value", "key2": "value3"})
Creates a new document with the specified document_id in the collection (Oh no! i messed up the value2. Let's fix that!)
Update document
>>> db.update_document("collection", "document_id", {"key": "value", "key2": "value2"})
Updates the document with the specified document_id in the collection
Delete document
>>> db.delete_document("collection", "document_id")
Note: This returns a Response object
Create new collection
>>> db.create_collection("new_collection")
Creates a new collection with the given name
Delete a collection
>>> db.delete_collection("new_collection")
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
Hashes for pydbconnect-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf24e1768e211ccdae1613dc2166d086e9b6db3dbf5ef99fd1d548ea9b2438d6 |
|
MD5 | f2e773a9de9ae138627f2a74dd8acea5 |
|
BLAKE2b-256 | 1e670aff0baf794941590f0c9ff55052b183ac22282602711f19c2f239fa5895 |