Skip to main content

A secure triglot database system for DNA-based cryptographic applications

Project description

DNACryptDB

Python Version License: MIT MySQL MongoDB Neo4j

A secure triglot database system combining MySQL, MongoDB, and Neo4j with military-grade encryption.

A polyglot database system with a custom query language that unifies MySQL (relational) and MongoDB (document store) operations.

Features

  • Unified Query Language**: One syntax for both MySQL and MongoDB
  • Automatic Backend Routing**: Structured data → MySQL, Flexible data → MongoDB
  • SQL Injection Proof**: Parameterized queries throughout
  • Script Files**: Write .dnacdb files and execute them
  • Interactive Mode**: Test queries in real-time
  • Easy Configuration**: Simple JSON config file

Installation

From PyPI (once published)

pip install dnacryptdb

Quick Start

1. Initialize Configuration

dnacryptdb init

This creates dnacdb.config.json with your database credentials:

{
  "mysql": {
    "host": "localhost",
    "user": "root",
    "password": "your_password",
    "database": "dnacryptdb"
  },
  "mongodb": {
    "uri": "mongodb://localhost:27017/",
    "database": "dnacryptdb"
  }
}

2. Create a Script File

Create hello.dnacdb:

-- Create a table in MySQL
MAKE TABLE users WITH (name:text, email:text, age:int);

-- Insert data
PUT INTO users DATA {"name": "Alice", "email": "alice@example.com", "age": 30};
PUT INTO users DATA {"name": "Bob", "email": "bob@example.com", "age": 25};

-- Query data
FETCH FROM users WHERE age > 26;

-- Create a collection in MongoDB
MAKE COLLECTION logs;

-- Insert flexible documents
PUT INTO logs DATA {"level": "INFO", "message": "Application started"};

-- Show all structures
SHOW TABLES;
SHOW COLLECTIONS;

3. Run the Script

dnacryptdb run hello.dnacdb

4. Interactive Mode

dnacryptdb interactive

dnacdb> MAKE TABLE products WITH (name:text, price:float);
dnacdb> PUT INTO products DATA {"name": "Laptop", "price": 999.99};
dnacdb> FETCH FROM products ALL;
dnacdb> exit

Query Language Reference

Create Structures

-- Create relational table (MySQL)
MAKE TABLE tablename WITH (field1:type1, field2:type2);

-- Create document collection (MongoDB)
MAKE COLLECTION collectionname;

Data Types

  • int / integer - Integer numbers
  • float / double - Floating point numbers
  • text / string - Text strings
  • date - Date values
  • datetime / timestamp - Date and time
  • bool / boolean - Boolean values

Insert Data

PUT INTO target DATA {"field": "value", "field2": 123};

Query Data

-- Query all records
FETCH FROM source ALL;

-- Query with condition
FETCH FROM source WHERE field > value;
FETCH FROM source WHERE field = "value";

Update Data

CHANGE IN target SET field = value WHERE condition;
CHANGE IN target SET field = "value" WHERE name = "Alice";

Delete Data

REMOVE FROM target WHERE condition;
REMOVE FROM target WHERE age < 18;

Show Structures

SHOW TABLES;       -- List MySQL tables
SHOW COLLECTIONS;  -- List MongoDB collections

Drop Structures

DROP tablename;

Comments

-- This is a comment
# This is also a comment

Examples

Example 1: User Management

-- Create users table
MAKE TABLE users WITH (username:text, email:text, age:int);

-- Insert users
PUT INTO users DATA {"username": "alice", "email": "alice@example.com", "age": 30};
PUT INTO users DATA {"username": "bob", "email": "bob@example.com", "age": 25};
PUT INTO users DATA {"username": "charlie", "email": "charlie@example.com", "age": 35};

-- Query users over 26
FETCH FROM users WHERE age > 26;

-- Update user age
CHANGE IN users SET age = 31 WHERE username = "alice";

-- Remove young users
REMOVE FROM users WHERE age < 30;

Example 2: Flexible Analytics

-- Create analytics collection
MAKE COLLECTION analytics;

-- Insert various event types
PUT INTO analytics DATA {"event": "page_view", "page": "/home", "timestamp": "2025-11-14T10:00:00"};
PUT INTO analytics DATA {"event": "click", "button": "signup", "metadata": {"campaign": "winter"}};
PUT INTO analytics DATA {"event": "purchase", "amount": 99.99, "items": ["laptop", "mouse"]};

-- Query all analytics
FETCH FROM analytics ALL;

Example 3: Mixed Data Types

-- Structured product data in MySQL
MAKE TABLE products WITH (name:text, price:float, stock:int);
PUT INTO products DATA {"name": "Laptop", "price": 999.99, "stock": 50};

-- Flexible review data in MongoDB
MAKE COLLECTION reviews;
PUT INTO reviews DATA {"product": "Laptop", "rating": 5, "comment": "Great!", "tags": ["fast", "reliable"]};

-- Query both
FETCH FROM products ALL;
FETCH FROM reviews ALL;

Architecture

Backend Selection

DNACryptDB automatically routes operations to the appropriate backend:

  • Structured Data (MySQL): Tables with defined schemas
  • Flexible Data (MongoDB): Collections with dynamic documents

Security

  • Parameterized Queries: All user input is treated as data, not code
  • No SQL Injection: Uses prepared statements for MySQL
  • Safe JSON Parsing: No eval() or unsafe code execution

Database Structure

MySQL (ACID Properties)
├── Tables with fixed schemas
├── Auto-increment primary keys
├── Type enforcement
└── Relational integrity

MongoDB (BASE Properties)
├── Flexible document schemas
├── Automatic timestamps
├── Nested data support
└── Eventual consistency

Command Line Reference

# Initialize configuration
dnacryptdb init
dnacryptdb init -o custom_config.json

# Run script files
dnacryptdb run script.dnacdb
dnacryptdb run script.dnacdb -c custom_config.json

# Interactive mode
dnacryptdb interactive
dnacryptdb interactive -c custom_config.json

# Help
dnacryptdb --help
dnacryptdb run --help

Use as Python Library

from dnacryptdb import DNACryptDB

# Initialize
db = DNACryptDB(config_file="dnacdb.config.json")

# Execute single query
result = db.execute("MAKE TABLE users WITH (name:text, age:int)")
print(result)

# Execute script file
results = db.execute_file("script.dnacdb")

# Close connections
db.close()

Requirements

  • Python 3.8+
  • MySQL 5.7+ or MariaDB 10.2+
  • MongoDB 4.0+

Development

# Clone repository
git clone https://github.com/Harshith2412/dnacryptdb.git
cd dnacryptdb

# Install in development mode
pip install -e .

# Run tests
python -m pytest tests/

# Format code
black dnacryptdb/

# Type checking
mypy dnacryptdb/

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built for the DNACrypt project at Northeastern University
  • Integrates MySQL and MongoDB for polyglot database operations
  • Part of MS in Cybersecurity research

Support

For issues, questions, or contributions, please visit:

Changelog

Version 1.0.0 (2025-11-14)

  • Initial release
  • Basic CRUD operations
  • MySQL and MongoDB integration
  • Script file execution
  • Interactive mode
  • Configuration management

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

dnacryptdb_harshith-2.0.0.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

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

dnacryptdb_harshith-2.0.0-py3-none-any.whl (39.8 kB view details)

Uploaded Python 3

File details

Details for the file dnacryptdb_harshith-2.0.0.tar.gz.

File metadata

  • Download URL: dnacryptdb_harshith-2.0.0.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for dnacryptdb_harshith-2.0.0.tar.gz
Algorithm Hash digest
SHA256 af93953010578737d7fd6568b2647b0f471f505793b8193cd24104377617a297
MD5 c9f7a275789ae109e6bdda0bcfe1b7c6
BLAKE2b-256 0efd8362a9f6b4d05360c1a47849f4ef52528f9d4242ee103709dfe11b821f3d

See more details on using hashes here.

File details

Details for the file dnacryptdb_harshith-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dnacryptdb_harshith-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89ca1fefb66c9adb28b11b65b898d1195c7f1eb8165c7ae7aea734bb26c7be11
MD5 2708486d05156ba1f22d14da75e4a2e6
BLAKE2b-256 d585e01a95ecc0aacbdc5cffa21c1510e346c7453ebd2a1304577600c93c9147

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