Unified data manipulation interface across multiple datastores.
Supported datastores: mysql, postgres, mariadb
Supported operators: =, !=, >, <, >=, <=, between, in, not in
Requires Python 3.9+.
pip install -e ".[dev]"All functions accept a single args dict.
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)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)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)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)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.
datastorex-mcpOr without installing:
python -m datastorex.mcp_serverAdd to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"datastorex": {
"command": "datastorex-mcp"
}
}
}claude mcp add datastorex -- datastorex-mcp| 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.
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