A GitHub based database system ('GitBase') which offers offline backups and optional encryption.
Project description
GitBase
GitBase is a Python package for custom databases powered by GitHub ("Gitbases"/"GitBase"), with encryption using cryptography. It allows you, as a python developer to have a quick and easy to use database without learning a whole new programming language. Furthermore, we offer offline backups for users of your application, this means their data can be saved, loaded, and deleted even if they have no internet. Moreover, the online version will be updated based on which file, the offline or online, is the latest.
Latest Update:
- Made GitBases raise exceptions for some errors, instead of just printing them. (helpful with debugging)
Example code:
# Example for GitBase 0.4.2
from gitbase import GitBase, PlayerDataSystem, DataSystem, KeyValue
from cryptography.fernet import Fernet
import sys
# Initialize GitHub database and encryption key
GITHUB_TOKEN = "YOUR_TOKEN"
REPO_OWNER = "YOUR_GITHUB_USERNAME"
REPO_NAME = "YOUR_REPO_NAME"
encryption_key = Fernet.generate_key()
# Setup GitBase with GitHub credentials
database = GitBase(GITHUB_TOKEN, REPO_OWNER, REPO_NAME)
player_data_system = PlayerDataSystem(db=database, encryption_key=encryption_key)
data_system = DataSystem(db=database, encryption_key=encryption_key)
# Upload and download example files to/from GitHub
database.upload_file(file_path="my_file.txt", remote_path="saved_files")
database.download_file(remote_path="my_file.txt", local_path="files")
# Define the Player class to manage individual player instances
class Player:
def __init__(self, username, score, password):
self.username = username
self.score = score
self.password = password
# Create a sample player instance
player = Player(username="john_doe", score=100, password="123")
# Save specific attributes of the player instance with encryption
player_data_system.save_account(
username="john_doe",
player_instance=player,
encryption=True,
attributes=["username", "score", "password"],
path="players"
)
# Load player data
player_data_system.load_account(username="john_doe", player_instance=player, encryption=True)
# Placeholder functions for game flow
def load_game():
print("Game starting...")
def main_menu():
sys.exit("Exiting game...")
# Check if an account exists and validate user password
if player_data_system.get_all(path="players"):
if player.password == input("Enter your password: "):
print("Login successful!")
load_game()
else:
print("Incorrect password!")
main_menu()
# Save key-value data with encryption
data_system.save_data(key="key_name", value=69, path="data", encryption=True)
# Load and display a specific key-value pair
loaded_key_value: KeyValue = data_system.load_data(key="key_name", encryption=True)
print(f"Key: {loaded_key_value.key}, Value: {loaded_key_value.value}")
# Retrieve and display all key-value pairs in the data path
print("All stored data:", data_system.get_all(path="data"))
# Delete specific key-value data
data_system.delete_data(key="key_name")
# Retrieve and display all player accounts
print("All player accounts:", player_data_system.get_all(path="players"))
# Delete a specific player account
player_data_system.delete_account(username="john_doe")
Consider using GitBase Web:
Gitbase Web:
Gitbase Web is an extension of the python project by Taireru LLC called GitBase. This extension allows the developer to veiw all of their saved data via the web.
Please note that to view said data you MUST use a private repo and use a website hosting service such as vercel.
Links:
GitBase: https://tairerullc.vercel.app/apps/gitbase.html
Website: https://tairerullc.vercel.app/
Contact 'tairerullc@gmail.com' for any inquires and we will get back at our latest expense. Thank you for using our product and happy coding!
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 gitbase-0.4.2.tar.gz.
File metadata
- Download URL: gitbase-0.4.2.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a73c64d17f8565b85543317b3e37368c08f319870de4cc27b07e5d3d3f80d91
|
|
| MD5 |
c376b2ff1a0149320480f096aa54c88a
|
|
| BLAKE2b-256 |
62707a32a51a577f2459cab797fa80682b91f1aee6c10b93f7259af112cfb699
|
File details
Details for the file gitbase-0.4.2-py3-none-any.whl.
File metadata
- Download URL: gitbase-0.4.2-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edfb1d57d11bdc752a00e76ce9bbd2308fc89b211bd9fe183de869260f3acdd0
|
|
| MD5 |
5b3bb29e6bb071845e2108442cd2f0ea
|
|
| BLAKE2b-256 |
1f6ad4f13788842ce208f31cff4f2aa979c3596ae64b550159ab4761a3e62b95
|