Skip to content

gmb9817/dbcord

Repository files navigation

dbcord

한국어 README

dbcord is an experimental Discord-native database for portfolio and learning use.

  • Guild = database instance
  • Category = namespace
  • Text channel = table or secondary index
  • Message = row or index entry
  • Attachment = large JSON blob or snapshot
  • Thread = row history
  • Discord guild search = query engine

This project intentionally uses Discord as the durable store. It does not use SQLite, Redis, or a local persistent index.

Status

dbcord is a demo-quality experiment, not a production database.

  • Only use it in dbcord-owned channels on a dedicated test guild
  • Do not point it at normal conversations
  • Do not use it for secrets, regulated data, or real workloads
  • Search is eventually consistent because Discord search is eventually consistent

Features

  • Discord-native tables, rows, blobs, and secondary indexes
  • Slash commands for init, CRUD, find, inspect, export, verify, reindex, vacuum, and snapshot
  • Small schema validation stored in Discord catalog messages
  • Blob rows backed by Discord attachments
  • Best-effort row history via message threads
  • Unit and engine tests that run without a live Discord server

Layout

dbcord-prod/
  #dbc-catalog
  #table-users
  #table-posts
  #idx-users-email
  #idx-users-role

Quick Start

  1. Create a Discord application and bot in the Developer Portal.
  2. Invite the bot to a dedicated test server.
  3. Enable Message Content Intent for development.
  4. Grant the bot at least:
    • View Channels
    • Send Messages
    • Read Message History
    • Attach Files
    • Manage Channels
    • Create Public Threads
    • Send Messages in Threads
    • Manage Messages for vacuum and hard-delete experiments

macOS/Linux:

python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
cp .env.example .env
python -m dbcord

Windows PowerShell:

python -m venv .venv
.venv\Scripts\activate
python -m pip install -r requirements.txt
Copy-Item .env.example .env
python -m dbcord

.env:

DISCORD_BOT_TOKEN=your-bot-token
DBCORD_GUILD_ID=your-test-guild-id

Example Flow

/dbc_init database:prod
/dbc_table_create database:prod table:users pk:id
/dbc_schema_set database:prod table:users schema_json:{"required":["id","email"],"properties":{"id":"str","email":"str","role":"str"}}
/dbc_index_create database:prod table:users field:email unique:true
/dbc_insert database:prod table:users key:u_1 value_json:{"id":"u_1","email":"a@example.com","role":"student"}
/dbc_find database:prod table:users where_json:{"role":"student"}
/dbc_update database:prod table:users key:u_1 patch_json:{"role":"admin"}
/dbc_verify database:prod table:users
/dbc_snapshot database:prod table:users

Query Model

Equality predicates become Discord search tokens.

{"role":"student","active":true}

Range-like predicates are post-filters after candidate rows are fetched:

{"age":{"$gte":18,"$lt":30}}

Supported post-filter operators:

  • $eq
  • $ne
  • $gt
  • $gte
  • $lt
  • $lte
  • $contains
  • $in
  • $exists
  • $prefix

If a matching secondary index exists, find() searches the index channel first and falls back to table search when the index is temporarily stale or not yet searchable.

Testing

python -m pip install -e .[dev]
python -m pytest

Recent local verification on April 30, 2026:

  • python -m pytest passed
  • live Discord guild checks passed for init, schema, index, CRUD, blob row, history, verify, snapshot, reindex, and vacuum

Compliance Notes

This project depends on Discord APIs and privileged intent behavior that can change over time.

  • Search Guild Messages requires READ_MESSAGE_HISTORY and is restricted by MESSAGE_CONTENT
  • if you ever scale beyond small private testing, review Discord’s current Developer Terms, Developer Policy, and Message Content rules again
  • this repository is best treated as an educational or portfolio experiment, not a platform product

Official references:

License

MIT

About

db made of discord

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages