daba by Klivolks.
Project description
daba by Klivolks
The daba library, developed by Klivolks, is a Python package designed to simplify the process of interacting with databases. It provides convenient and easy-to-use methods for carrying out common database operations such as querying, inserting, updating, and deleting data. Primarily focused on Mongo is expected to grow to other Query languages.
Installation
This package can be installed using pip:
pip install daba
Environment Variables
Two environment variables need to be set:
MONGO_URL: This is the URL of the MongoDB server.MONGO_DB: This is the name of the MongoDB database to interact with.
And optional variables are
MONGO_POOL_SIZE: This is the default pool size of the MongoDB database.
These can be set in an .env file that can be loaded with python-dotenv. Remember not to commit sensitive data (like your database URLs) to version control!
Example usage
In this example, the collection class from the daba.Mongo module is being used to interact with a MongoDB collection.
You can create a collection object using the collection method:
db_obj = collection('test')
The collection object has several methods to interact with the MongoDB collection.
Methods
Below are the methods available in the daba library's collection class, along with brief descriptions of what they do:
init_db(): Initializes the MongoDB database.close_db(): Closes the MongoDB database connection.get(query): Returns documents that match the query.find(query): Aggregate function.put(data): Inserts a single document into the collection.putMany(data): Inserts multiple documents into the collection.set(query, new_data): Updates a single document that matches the query.inc(query, data_to_increment): Increments the value of specific fields in a document that matches the query.setMany(query, new_data): Updates multiple documents that match the query.getOne(query): Returns a single document that matches the query.getAfterCount(query, field): Returns a document after incrementing the value of a specific field.deleteOne(query): Deletes a single document that matches the query.deleteMany(query): Deletes multiple documents that match the query.removeElement(query, element): Removes an element from an array in the documents that match the query.count(query): Counts the documents that match the query.createIndex(field, options): Creates index to the current table. Can use list of tuple of indexes or a single string.
Running Tests
This library includes a suite of unit tests. To run the tests, execute the script with a Python interpreter. Ensure the .env file is in the same directory as the script.
python test_daba.py
Note
This README is not exhaustive, and is intended to be a brief introduction to the functionality provided by the daba library. For a full list of functionality and options, please refer to the official documentation.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file daba-1.0.2.tar.gz.
File metadata
- Download URL: daba-1.0.2.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e09ba0be2b9cc4d43f84551085f650a199cc7f4ede0b61ff7e76f04b925e1eb
|
|
| MD5 |
043ee91fe969f2e2639575ba27089fb2
|
|
| BLAKE2b-256 |
1ba501ce3a8525788617840a111121bfe602e453c99d48565d6ce4838e1bec6c
|
Provenance
The following attestation bundles were made for daba-1.0.2.tar.gz:
Publisher:
release.yml on klivolks/DaBa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
daba-1.0.2.tar.gz -
Subject digest:
5e09ba0be2b9cc4d43f84551085f650a199cc7f4ede0b61ff7e76f04b925e1eb - Sigstore transparency entry: 157730725
- Sigstore integration time:
-
Permalink:
klivolks/DaBa@c1f9c953295f4bf9b325d320f9109dc26dc3cb99 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/klivolks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c1f9c953295f4bf9b325d320f9109dc26dc3cb99 -
Trigger Event:
release
-
Statement type:
File details
Details for the file daba-1.0.2-py3-none-any.whl.
File metadata
- Download URL: daba-1.0.2-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e315245783fec3ad5a37926385b162494a8ac0c482fb1b2fda375af355106fa1
|
|
| MD5 |
c0034ede26ecedce7d49944b5c501e03
|
|
| BLAKE2b-256 |
f60cdfdd6034d9a65ef9706f5848efddd3838d7c71e00bb3253974f055f7af29
|
Provenance
The following attestation bundles were made for daba-1.0.2-py3-none-any.whl:
Publisher:
release.yml on klivolks/DaBa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
daba-1.0.2-py3-none-any.whl -
Subject digest:
e315245783fec3ad5a37926385b162494a8ac0c482fb1b2fda375af355106fa1 - Sigstore transparency entry: 157730726
- Sigstore integration time:
-
Permalink:
klivolks/DaBa@c1f9c953295f4bf9b325d320f9109dc26dc3cb99 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/klivolks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c1f9c953295f4bf9b325d320f9109dc26dc3cb99 -
Trigger Event:
release
-
Statement type: