Skip to main content

DataBase with GitHub Repo

Project description

Description

An easy-to-use cloud database that uses a GitHub repository to store data. # Example Using an example, I will show you how to create a database for a Discord server using pycord

import discord
from discord.ext import commands,tasks
import json
from dbkirosake import DBKirosake
from settings.config import *

DB=DBKirosake(
    actoken, # access token your GitHub account
    repos # your private/public repository
)

intents = discord.Intents.all()

client = commands.Bot(
    command_prefix=prefix,
    intents=intents,
    bot=True
)
client.remove_command('help')

@client.event
async def on_ready():
    for guild in client.guilds:
        for member in guild.members:
            db={
                'lvl':1,
                'cash':10
            }
            await DB.create_db(
                nameDB='test',
                folder=guild.id,
                ids=member.id,
                database=db
            )

client.run(token)

A database is created with the name nameDB which contains a folder called guild.id and file users.json

Structure ../test/1234567890/users.json The users.json file contains the list:

{
    "here ids": {
        "lvl": 1,
        "cash": 10
    }
}

Data update

DB=DBKirosake(
    actoken,
    repos
)
file=f"test/{ctx.guild.id}/users.json" # /repo/test/1234567890/users.json
await DB.update_more(
    file, # connect file
    str(member.id), # get user in users.jsom
    'cash', # what are we changing
    100, # how much do we change
    'int', # data type int/float/str
    'add' # change type add/replace
)

Get dictionary

file=f"test/{member.guild.id}/users.json"
db=await DB.get(file)

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

db-kirosake-0.3.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

db_kirosake-0.3-py3-none-any.whl (4.2 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