Skip to main content

MatsushibaDB - Next-Generation SQL Database with Complete Enterprise Features

Project description

matsushiba-db

MatsushibaDB

MatsushibaDB

Next-Generation SQL Database by Matsushiba Systems

A powerful Python package that provides both client and server functionality with inbuilt SQLite standalone - no external dependencies required!

🚀 Installation

pip install matsushiba-db

📖 Quick Start

Start Server (Inbuilt SQLite)

# Start MatsushibaDB server with inbuilt SQLite
matsushiba-db --host localhost --port 8000

# Or with all enterprise features
matsushiba-db --enable-audit --enable-encryption --enable-rbac --enable-rate-limit

Use as Client

from matsushiba_db import MatsushibaDBClient

# Create HTTP client
client = MatsushibaDBClient('http://localhost:8000')

# Query database
result = client.query('SELECT * FROM users')
print(result['data'])

📦 Package Features

✅ Standalone SQLite Database

  • 🔧 Inbuilt SQLite: No external database installation required
  • 📦 Self-Contained: Everything included in the Python package
  • 🚀 Zero Configuration: Works out of the box
  • 💾 File-Based: Simple database files, no server setup needed

✅ Server Mode

  • Standalone SQLite Database Server
  • Multi-Protocol Support: HTTP, HTTPS, WebSocket, TCP
  • Enterprise Security: Rate limiting, CORS, Helmet security
  • High Performance: Optimized SQLite settings
  • SSL/HTTPS Support: Built-in SSL certificate support

✅ Client Mode

  • HTTP/HTTPS Client: REST API client
  • WebSocket Client: Real-time bidirectional communication
  • TCP Client: Low-latency TCP connections
  • Promise-based API: Modern async/await support

🛠 Usage

Server Mode

Start Server

# Basic server
matsushiba-db

# Custom port and database
matsushiba-db --port 9000 --database myapp.db

# SSL/HTTPS server
matsushiba-db --ssl-cert cert.pem --ssl-key key.pem

Server Options

  • --host HOST: Server host (default: localhost)
  • --port PORT: Server port (default: 8000)
  • --database FILE: Database file (default: matsushiba.db)
  • --ssl-cert FILE: SSL certificate file
  • --ssl-key FILE: SSL private key file
  • --enable-audit: Enable audit logging
  • --enable-encryption: Enable file encryption
  • --enable-rbac: Enable role-based access control
  • --enable-rate-limit: Enable rate limiting

Server Endpoints

  • GET /: Server information
  • GET /health: Health check
  • POST /api/query: Execute SELECT queries
  • POST /api/execute: Execute INSERT/UPDATE/DELETE
  • POST /api/batch: Execute multiple queries
  • POST /api/transaction: Execute ACID transactions
  • GET /api/tables: List all tables
  • GET /api/table/:name: Get table schema
  • POST /api/table/:name: Create table
  • DELETE /api/table/:name: Drop table
  • GET /api/users: List users (admin)
  • POST /api/users: Create user (admin)
  • GET /api/audit: Get audit logs (admin)
  • GET /api/metrics: Get performance metrics

Client Mode

HTTP Client

from matsushiba_db import MatsushibaDBClient

# Create client
client = MatsushibaDBClient('http://localhost:8000')

# Authenticate
response = client.post('/api/auth/login', json={
    'username': 'admin',
    'password': 'admin123'
})
token = response.json()['token']

# Set authorization header
client.headers['Authorization'] = f'Bearer {token}'

# Query data
result = client.post('/api/query', json={
    'sql': 'SELECT * FROM users WHERE age > ?',
    'params': [18]
})
print(result.json()['data'])

# Execute statements
result = client.post('/api/execute', json={
    'sql': 'INSERT INTO users (name, age) VALUES (?, ?)',
    'params': ['John', 25]
})
print(result.json()['changes'])

Batch Operations

# Execute multiple queries
result = client.post('/api/batch', json={
    'queries': [
        {'sql': 'INSERT INTO users (name) VALUES (?)', 'params': ['Alice']},
        {'sql': 'INSERT INTO users (name) VALUES (?)', 'params': ['Bob']},
        {'sql': 'SELECT COUNT(*) as total FROM users'}
    ]
})
print(result.json()['results'])

ACID Transactions

# Execute transaction
result = client.post('/api/transaction', json={
    'queries': [
        {'sql': 'UPDATE accounts SET balance = balance - 100 WHERE id = 1'},
        {'sql': 'UPDATE accounts SET balance = balance + 100 WHERE id = 2'}
    ]
})
print(result.json()['success'])  # True if all succeeded, False if rolled back

🔧 API Reference

Client Methods

query(sql, params)

Execute a SELECT query and return results.

result = client.post('/api/query', json={
    'sql': 'SELECT * FROM users WHERE age > ?',
    'params': [18]
})
# Returns: {'success': True, 'data': [...], 'count': number}

execute(sql, params)

Execute INSERT/UPDATE/DELETE statements.

result = client.post('/api/execute', json={
    'sql': 'INSERT INTO users (name) VALUES (?)',
    'params': ['John']
})
# Returns: {'success': True, 'changes': number, 'lastID': number}

Server Configuration

Environment Variables

MATSUSHIBADB_HOST=localhost
MATSUSHIBADB_PORT=8000
MATSUSHIBADB_DATABASE=matsushiba.db
MATSUSHIBADB_SSL_CERT=cert.pem
MATSUSHIBADB_SSL_KEY=key.pem

🔒 Security Features

  • Rate Limiting: Prevents request spam (1000 requests/hour)
  • CORS Support: Configurable cross-origin requests
  • JWT Authentication: Secure token-based authentication
  • Password Hashing: bcrypt password hashing
  • Input Validation: SQL injection protection
  • SSL/HTTPS: Encrypted connections
  • RBAC: Role-based access control (admin, user, readonly, guest)
  • Audit Logging: Complete operation logging
  • File Encryption: AES-256-CBC encryption for database files

📊 Performance

  • WAL Mode: Write-Ahead Logging for better concurrency
  • Connection Pooling: Efficient connection management
  • Compression: Gzip compression for responses
  • Caching: Optimized SQLite cache settings
  • Inbuilt SQLite: No external database dependencies

🌐 Multi-Protocol Support

Protocol Use Case Performance Features
HTTP/HTTPS Web APIs, REST Good CORS, SSL, Compression
WebSocket Real-time apps Excellent Bidirectional, Low latency
TCP High-performance Best Minimal overhead

📝 Examples

Complete Application (Standalone)

from matsushiba_db import MatsushibaDBServer
import asyncio

# Start server with inbuilt SQLite
server = MatsushibaDBServer(
    host='localhost',
    port=8000,
    database='myapp.db',
    enable_audit_log=True,
    enable_encryption=True,
    enable_rbac=True,
    enable_rate_limit=True
)

# Start server
asyncio.run(server.start())

# Client usage
from matsushiba_db import MatsushibaDBClient

client = MatsushibaDBClient('http://localhost:8000')

# Authenticate
response = client.post('/api/auth/login', json={
    'username': 'admin',
    'password': 'admin123'
})
token = response.json()['token']
client.headers['Authorization'] = f'Bearer {token}'

# Create table
client.post('/api/table/users', json={
    'sql': '''
        CREATE TABLE users (
            id INTEGER PRIMARY KEY,
            name TEXT NOT NULL,
            email TEXT UNIQUE
        )
    '''
})

# Insert data
client.post('/api/execute', json={
    'sql': 'INSERT INTO users (name, email) VALUES (?, ?)',
    'params': ['John', 'john@example.com']
})

# Query data
result = client.post('/api/query', json={
    'sql': 'SELECT * FROM users'
})
print(result.json()['data'])

🚀 Deployment

Production Server (Standalone)

# Install globally
pip install matsushiba-db

# Start production server with inbuilt SQLite
matsushiba-db --host 0.0.0.0 --port 80 --database /var/lib/matsushiba/production.db

Docker

FROM python:3.11
RUN pip install matsushiba-db
EXPOSE 8000
CMD ["matsushiba-db", "--host", "0.0.0.0", "--port", "8000"]

📄 License

MatsushibaDB is proprietary software by Matsushiba Systems. See License Terms for full details.

🆘 Support


MatsushibaDB - The future of SQL databases is here! 🚀

Part of Matsushiba Systems

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

matsushibadb-1.0.1.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matsushibadb-1.0.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file matsushibadb-1.0.1.tar.gz.

File metadata

  • Download URL: matsushibadb-1.0.1.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for matsushibadb-1.0.1.tar.gz
Algorithm Hash digest
SHA256 16eaff1895a2bce50bf32f4e6b72890bcd73f672a0c7d6c4a21922f9bb0c22d0
MD5 ac0060f54c98964695a84116548bd6e0
BLAKE2b-256 fe5aee07abe4982cb294b528216a01bfa6e1af295dfd302c4e7daedf6286eebb

See more details on using hashes here.

File details

Details for the file matsushibadb-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: matsushibadb-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for matsushibadb-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4c26c5b8e66eb3d352f49cb59abc600f6838cdf767e4135e49137156c6c2e3b
MD5 5422de69b166c5c851d022c267c605fc
BLAKE2b-256 a8bf253461ae8f0136f8825fe9eeb9b46a565ed6282d7f45d1d7c0f500b98900

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page