Skip to content

kanekargauri/datastoreX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

datastorex

Unified data manipulation interface across multiple datastores.

Supported datastores: mysql, postgres, mariadb
Supported operators: =, !=, >, <, >=, <=, between, in, not in

Requires Python 3.9+.


Install

pip install -e ".[dev]"

Usage

All functions accept a single args dict.

insert

import datastorex

args = {
    "connection_info": {
        "type": "mysql", "host": "localhost", "namespace": "mydb",
        "user": "user", "password": "pass", "port": 3306
    },
    "tablename": "orders",
    "data_columns": ["customer_id", "amount"],
    "values": [42, 99.99],
}
last_row_id = datastorex.insert(args)

update

filter is required to prevent accidental full-table updates.

args = {
    "connection_info": { ... },
    "tablename": "orders",
    "set_columns": ["amount"],
    "set_values": [199.99],
    "filter": [{"operand": "customer_id", "operator": "=", "value": 42}],
}
rows_affected = datastorex.update(args)

delete

args = {
    "connection_info": { ... },
    "tablename": "orders",
    "filter": [
        {"operand": "created_at", "operator": "between", "value": ["2015-12-01", "2015-12-31"]},
        {"operand": "status", "operator": "in", "value": ["cancelled", "refunded"]},
    ],
}
rows_affected = datastorex.delete(args)

select

Returns a list of dicts. All values are parameterized — safe against SQL injection.

args = {
    "connection_info": { ... },
    "tablename": "orders",
    "select_fields": ["id", "customer_id", "amount"],
    "filter": [{"operand": "amount", "operator": ">", "value": 50.0}],
    "order_by": "amount desc",
    "limit": "20",
    "offset": "0",
}
rows = datastorex.select(args)

MCP Server

datastorex ships as an MCP server, exposing db_select, db_insert, db_update, and db_delete as tools that any MCP-compatible client (Claude Desktop, Claude Code, etc.) can call.

Run the server

datastorex-mcp

Or without installing:

python -m datastorex.mcp_server

Claude Desktop config

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "datastorex": {
      "command": "datastorex-mcp"
    }
  }
}

Claude Code config

claude mcp add datastorex -- datastorex-mcp

Available tools

Tool Description
db_select Query rows with optional filter, order, limit, offset
db_insert Insert a single row, returns last inserted ID
db_update Update rows matching a filter, returns rows affected
db_delete Delete rows matching a filter, returns rows affected

All tools accept db_type ("mysql", "postgres", "mariadb"), connection params, and a filter list of {"operand", "operator", "value"} objects.


Running tests

Validation and security tests run without a database:

pytest datastorex/tests/ -m "not integration"

Integration tests require live database instances:

TEST_DB_HOST=localhost TEST_DB_NAME=testtest TEST_DB_USER=testtest TEST_DB_PASS=testtest \
    pytest datastorex/tests/ -m integration

About

datastoreX is a abstraction layer over different datastores. a common layer to do dml's. current support is for mysql

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages