sedql


Namesedql JSON
Version 1.0.10 PyPI version JSON
download
home_pagehttps://github.com/holy182/sed-cli
SummaryPython SDK for SED (Semantic Entities Designs) - Full TypeScript CLI Integration
upload_time2025-08-15 17:11:42
maintainerSED Team
docs_urlNone
authorSED Team
requires_python>=3.8
licenseNone
keywords semantic database ai dsl data-modeling automation sed cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SEDQL Python SDK

**Python SDK for SED (Semantic Entities Designs) - Full TypeScript CLI Integration**

[![PyPI version](https://badge.fury.io/py/sedql.svg)](https://badge.fury.io/py/sedql)
[![Python versions](https://img.shields.io/pypi/pyversions/sedql.svg)](https://pypi.org/project/sedql/)
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL%203.0-green.svg)](https://opensource.org/licenses/AGPL-3.0)

**SED automatically converts your raw database into an AI-ready semantic layer with intelligent business rules.**

## 🚀 Quick Start

### Installation

```bash
# Install the Python package
pip install sedql

# Install the SED CLI (required)
npm install -g sed-cli
```

### Basic Usage

```python
from sedql import SEDClient

# Initialize enhanced client (no database URL needed)
sed = SEDClient()

# Initialize SED with database connection
sed.init()

# Build semantic layer
sed.build()

# Query with natural language
result = sed.query("Show me customers with high revenue")
print(result)

# Query with AI integration using environment variables (RECOMMENDED)
# Set your API keys in environment variables:
# export OPENAI_API_KEY="your-openai-api-key"
# export ANTHROPIC_API_KEY="your-anthropic-api-key"

# Simple OpenAI query (automatically uses OPENAI_API_KEY)
ai_result = sed.query_with_openai("Forecast revenue for Q3 2024")

# Simple Anthropic query (automatically uses ANTHROPIC_API_KEY)
claude_result = sed.query_with_anthropic("Identify customer retention opportunities")

# Access rich response with all features
print(f"Data: {ai_result['query_result']}")
print(f"AI Analysis: {ai_result['ai_enhancement']['ai_response']}")
print(f"Risk Level: {ai_result['risk_assessment']['risk_level']}")
print(f"Business Context: {ai_result['business_context']}")

# Advanced: Use your own AI client
import openai
openai_client = openai.OpenAI(api_key="your-key")  # Only if you prefer this approach

custom_ai_result = sed.query_with_ai({
    "natural_language": "Analyze sales patterns",
    "ai_client": openai_client,
    "ai_service": "custom",
    "ai_model": "gpt-4"
})
```

## ✨ What You Get

### **Full TypeScript CLI Integration**
- ✅ **Business Rules Engine** - Query validation & governance
- ✅ **Schema Change Detection** - Automatic change monitoring
- ✅ **Security Validation** - Business rule enforcement
- ✅ **Audit Trail** - Rule evaluation tracking
- ✅ **Performance Optimization** - Query analysis
- ✅ **Business Context** - Semantic layer with domain knowledge
- ✅ **AI Integration Framework** - Works with YOUR AI providers

### **AI Integration Philosophy**
**SED provides the security, governance, and business context. You provide the AI.**

- 🔒 **SED handles**: Data security, business rules, query validation, schema management
- 🤖 **You handle**: AI service selection, API keys, model choice, AI processing
- 🔗 **Together**: Secure, governed AI-powered data analysis

### **Rich Response Structure**
```python
response = {
    'query_result': {...},      # Query execution results
    'ai_enhancement': {...},    # AI processing results from YOUR service
    'business_context': {...},  # Business domain knowledge from SED
    'insights': {...},          # Data insights and analysis
    'risk_assessment': {...},   # Security risk analysis from SED
    'metadata': {...}           # Query metadata
}
```

## 🔗 AI Integration Examples

### **Environment Variables (RECOMMENDED)**
```python
from sedql import SEDClient

# Set environment variables first:
# export OPENAI_API_KEY="your-key"
# export ANTHROPIC_API_KEY="your-key"

# Initialize SED
sed = SEDClient()
sed.init()
sed.build()

# Simple queries using environment variables
openai_result = sed.query_with_openai("Analyze customer retention patterns")
claude_result = sed.query_with_anthropic("Identify revenue optimization opportunities")

print(f"OpenAI Analysis: {openai_result['ai_enhancement']['ai_response']}")
print(f"Claude Analysis: {claude_result['ai_enhancement']['ai_response']}")
```

### **OpenAI Integration (Manual)**
```python
import openai
from sedql import SEDClient

# Initialize SED
sed = SEDClient()
sed.init()
sed.build()

# Set up OpenAI client
openai_client = openai.OpenAI(api_key="your-openai-api-key")

# Query with AI enhancement
result = sed.query_with_ai({
    "natural_language": "Analyze customer retention patterns",
    "ai_client": openai_client,
    "ai_service": "custom",
    "ai_model": "gpt-4"
})

print(f"AI Analysis: {result['ai_enhancement']['ai_response']}")
```

### **Anthropic Integration (Manual)**
```python
import anthropic
from sedql import SEDClient

# Initialize SED
sed = SEDClient()
sed.init()
sed.build()

# Set up Anthropic client
anthropic_client = anthropic.Anthropic(api_key="your-anthropic-api-key")

# Query with AI enhancement
result = sed.query_with_ai({
    "natural_language": "Identify revenue optimization opportunities",
    "ai_client": anthropic_client,
    "ai_service": "custom",
    "ai_model": "claude-3-sonnet-20240229"
})

print(f"AI Analysis: {result['ai_enhancement']['ai_response']}")
```

### **Custom AI Service Integration**
```python
from sedql import SEDClient

# Your custom AI service
class CustomAIService:
    def generate(self, prompt, max_tokens=1000):
        # Your AI logic here
        return f"AI analysis: {prompt[:50]}..."

# Initialize SED
sed = SEDClient()
sed.init()
sed.build()

# Use your custom AI service
custom_ai = CustomAIService()

result = sed.query_with_ai({
    "natural_language": "Forecast sales for next quarter",
    "ai_client": custom_ai,
    "ai_model": "custom-model"
})

print(f"Custom AI Analysis: {result['ai_enhancement']['ai_response']}")
```

## 📋 Requirements

- **Python**: 3.8+
- **SED CLI**: `npm install -g sed-cli` (provides all the advanced features)
- **Database**: PostgreSQL, MySQL, SQLite (handled by CLI config)
- **AI Services**: Install your preferred AI provider packages as needed

## 🔧 Installation

### 1. Install SED CLI (Required)
```bash
npm install -g sed-cli
```

### 2. Install Python Package
```bash
pip install sedql
```

### 3. Set Up AI API Keys (Optional but Recommended)
```bash
# For OpenAI
export OPENAI_API_KEY="your-openai-api-key-here"

# For Anthropic
export ANTHROPIC_API_KEY="your-anthropic-api-key-here"

# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.) to make permanent
echo 'export OPENAI_API_KEY="your-key"' >> ~/.bashrc
echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.bashrc
```

### 4. Verify Setup
```python
from sedql import SEDClient

# Check what AI services are available
sed = SEDClient()
status = sed.get_ai_environment_status()
print(f"Available AI services: {status['available_services']}")
```

## 🎯 API Reference

### SEDClient

Main client class that provides full access to SED CLI capabilities.

#### Core Methods
- `init(force=False)` - Initialize SED with database connection
- `build(output_file=None)` - Build or rebuild semantic layer
- `query(natural_language_query, verbose=False)` - Query database using natural language
- `query_with_ai(query_params)` - Query with AI integration and full SED features

#### Advanced Features
- `detect_changes(format="json")` - Detect schema changes with analysis
- `get_status()` - Get current SED status with business rules
- `export_config(format="json", output_file=None)` - Export configuration
- `validate()` - Validate semantic layer and business rules
- `get_semantic_mapping()` - Get business entities and relationships

## 🎯 Use Cases

- **Data Engineering**: Programmatically build semantic layers
- **Data Science**: Query databases using natural language with AI
- **Application Integration**: Embed SED functionality in Python apps
- **Automation**: Script database discovery and mapping
- **AI Development**: Provide semantic context to LLMs
- **Data Governance**: Automatic PII protection and compliance

## 🔍 Examples

### Enhanced Query with AI
```python
from sedql import SEDClient

# Create enhanced client
sed = SEDClient()

# Execute AI-enhanced query with full SED features
response = sed.query_with_ai({
    "natural_language": "Show me customer retention trends",
    "ai_model": "gpt-4",
    "business_context": "Customer analytics and retention analysis"
})

# Access all the rich features
print("🎯 Query Results:")
print(f"   Data: {response['query_result']}")

print("🔒 Security & Compliance:")
print(f"   Risk Level: {response['risk_assessment']['risk_level']}")
print(f"   Validation: {response['validation']}")

print("💼 Business Intelligence:")
print(f"   Context: {response['business_context']}")
print(f"   Insights: {response['insights']}")
```

### Business Rules and Validation
```python
# Get current status with business rules
status = sed.get_status()
print(f"Business Rules: {status.get('rules', {})}")

# Validate semantic layer
validation = sed.validate()
print(f"Validation Status: {validation.get('summary', {}).get('status')}")

# Detect schema changes
changes = sed.detect_changes(format="json")
print(f"Total Changes: {changes.get('analysis', {}).get('total_changes', 0)}")
```

## 🌟 Why SEDQL Python SDK?

### **Full CLI Power in Python**
- Access to all `sed-cli` features from Python
- Business rules engine and validation
- Schema change detection and analysis
- Rich response processing and insights

### **Enterprise Ready**
- Local-first architecture (no data leaves your machine)
- Automatic PII protection and compliance
- Business rule generation and enforcement
- Professional-grade security and audit trails

### **AI Integration Ready**
- Semantic layer for LLM context
- Business terminology mapping
- Risk assessment and validation
- Custom AI client integration

## 🎯 How AI Integration Works

### **SED's Role (What We Provide)**
- 🔒 **Security & Governance**: Business rules, PII protection, access control
- 🏗️ **Business Context**: Semantic layer, entity relationships, business logic
- ✅ **Query Validation**: Ensures AI requests are safe and compliant
- 📊 **Data Access**: Secure database queries with business rule enforcement
- 🚫 **Risk Assessment**: Evaluates query safety before execution

### **Your Role (What You Provide)**
- 🤖 **AI Service**: OpenAI, Anthropic, or your custom AI service
- 🔑 **API Keys**: Your credentials for the AI service
- 🎛️ **Model Selection**: Which AI model to use (GPT-4, Claude, etc.)
- 💰 **Cost Management**: You control your AI service usage and costs

### **The Integration Flow**
1. **You ask a question** → "Analyze customer retention patterns"
2. **SED provides context** → Business entities, relationships, security rules
3. **SED validates the request** → Checks business rules and security policies
4. **SED executes the query** → Gets data safely from your database
5. **Your AI service analyzes** → Processes the data and provides insights
6. **SED returns everything** → Query results + AI analysis + security context

### **Why This Approach?**
- ✅ **No vendor lock-in**: Use any AI service you prefer
- ✅ **Cost control**: You manage your AI service costs
- ✅ **Security**: SED handles data governance, AI handles analysis
- ✅ **Flexibility**: Switch between AI providers as needed
- ✅ **Compliance**: Business rules are enforced regardless of AI service

## 🔗 Related Projects

- **[sed-cli](https://www.npmjs.com/package/sed-cli)** - Core TypeScript CLI (npm package)
- **[GitHub Repository](https://github.com/holy182/sed-cli)** - Source code and documentation

## 📄 License

This project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](https://github.com/holy182/sed-cli/blob/main/LICENSE) file for details.

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guidelines](https://github.com/holy182/sed-cli/blob/main/CONTRIBUTING.md) for details.

---

**Built with ❤️ by the SED Team**

## 🔒 Security & API Key Management

### **Best Practices for API Keys**
- ✅ **Use environment variables** - Never hardcode API keys in your code
- ✅ **Use .env files** - For local development (add .env to .gitignore)
- ✅ **Use secret management** - For production deployments
- ✅ **Rotate keys regularly** - Keep your API keys secure

### **Environment Variable Setup**
```bash
# Local development (.env file)
echo "OPENAI_API_KEY=your-key-here" > .env
echo "ANTHROPIC_API_KEY=your-key-here" >> .env

# Production (set in your deployment environment)
export OPENAI_API_KEY="your-production-key"
export ANTHROPIC_API_KEY="your-production-key"
```

### **What SED Does NOT Do**
- ❌ **Store API keys** - We never see or store your credentials
- ❌ **Make external calls** - All AI calls go through your environment
- ❌ **Track usage** - We don't monitor your AI service usage
- ❌ **Share data** - Your data stays local, AI calls go to your provider

### **What SED DOES Do**
- ✅ **Provide security** - Business rules, PII protection, access control
- ✅ **Validate queries** - Ensure AI requests are safe and compliant
- ✅ **Manage context** - Provide business intelligence and semantic mapping
- ✅ **Enforce governance** - Apply your company's data policies

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/holy182/sed-cli",
    "name": "sedql",
    "maintainer": "SED Team",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "semantic, database, ai, dsl, data-modeling, automation, sed, cli",
    "author": "SED Team",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d1/a7/5cc62d76d5696191d03163d2442d76ca092fd575bb357231ea592861e6d8/sedql-1.0.10.tar.gz",
    "platform": null,
    "description": "# SEDQL Python SDK\r\n\r\n**Python SDK for SED (Semantic Entities Designs) - Full TypeScript CLI Integration**\r\n\r\n[![PyPI version](https://badge.fury.io/py/sedql.svg)](https://badge.fury.io/py/sedql)\r\n[![Python versions](https://img.shields.io/pypi/pyversions/sedql.svg)](https://pypi.org/project/sedql/)\r\n[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL%203.0-green.svg)](https://opensource.org/licenses/AGPL-3.0)\r\n\r\n**SED automatically converts your raw database into an AI-ready semantic layer with intelligent business rules.**\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\n### Installation\r\n\r\n```bash\r\n# Install the Python package\r\npip install sedql\r\n\r\n# Install the SED CLI (required)\r\nnpm install -g sed-cli\r\n```\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom sedql import SEDClient\r\n\r\n# Initialize enhanced client (no database URL needed)\r\nsed = SEDClient()\r\n\r\n# Initialize SED with database connection\r\nsed.init()\r\n\r\n# Build semantic layer\r\nsed.build()\r\n\r\n# Query with natural language\r\nresult = sed.query(\"Show me customers with high revenue\")\r\nprint(result)\r\n\r\n# Query with AI integration using environment variables (RECOMMENDED)\r\n# Set your API keys in environment variables:\r\n# export OPENAI_API_KEY=\"your-openai-api-key\"\r\n# export ANTHROPIC_API_KEY=\"your-anthropic-api-key\"\r\n\r\n# Simple OpenAI query (automatically uses OPENAI_API_KEY)\r\nai_result = sed.query_with_openai(\"Forecast revenue for Q3 2024\")\r\n\r\n# Simple Anthropic query (automatically uses ANTHROPIC_API_KEY)\r\nclaude_result = sed.query_with_anthropic(\"Identify customer retention opportunities\")\r\n\r\n# Access rich response with all features\r\nprint(f\"Data: {ai_result['query_result']}\")\r\nprint(f\"AI Analysis: {ai_result['ai_enhancement']['ai_response']}\")\r\nprint(f\"Risk Level: {ai_result['risk_assessment']['risk_level']}\")\r\nprint(f\"Business Context: {ai_result['business_context']}\")\r\n\r\n# Advanced: Use your own AI client\r\nimport openai\r\nopenai_client = openai.OpenAI(api_key=\"your-key\")  # Only if you prefer this approach\r\n\r\ncustom_ai_result = sed.query_with_ai({\r\n    \"natural_language\": \"Analyze sales patterns\",\r\n    \"ai_client\": openai_client,\r\n    \"ai_service\": \"custom\",\r\n    \"ai_model\": \"gpt-4\"\r\n})\r\n```\r\n\r\n## \u2728 What You Get\r\n\r\n### **Full TypeScript CLI Integration**\r\n- \u2705 **Business Rules Engine** - Query validation & governance\r\n- \u2705 **Schema Change Detection** - Automatic change monitoring\r\n- \u2705 **Security Validation** - Business rule enforcement\r\n- \u2705 **Audit Trail** - Rule evaluation tracking\r\n- \u2705 **Performance Optimization** - Query analysis\r\n- \u2705 **Business Context** - Semantic layer with domain knowledge\r\n- \u2705 **AI Integration Framework** - Works with YOUR AI providers\r\n\r\n### **AI Integration Philosophy**\r\n**SED provides the security, governance, and business context. You provide the AI.**\r\n\r\n- \ud83d\udd12 **SED handles**: Data security, business rules, query validation, schema management\r\n- \ud83e\udd16 **You handle**: AI service selection, API keys, model choice, AI processing\r\n- \ud83d\udd17 **Together**: Secure, governed AI-powered data analysis\r\n\r\n### **Rich Response Structure**\r\n```python\r\nresponse = {\r\n    'query_result': {...},      # Query execution results\r\n    'ai_enhancement': {...},    # AI processing results from YOUR service\r\n    'business_context': {...},  # Business domain knowledge from SED\r\n    'insights': {...},          # Data insights and analysis\r\n    'risk_assessment': {...},   # Security risk analysis from SED\r\n    'metadata': {...}           # Query metadata\r\n}\r\n```\r\n\r\n## \ud83d\udd17 AI Integration Examples\r\n\r\n### **Environment Variables (RECOMMENDED)**\r\n```python\r\nfrom sedql import SEDClient\r\n\r\n# Set environment variables first:\r\n# export OPENAI_API_KEY=\"your-key\"\r\n# export ANTHROPIC_API_KEY=\"your-key\"\r\n\r\n# Initialize SED\r\nsed = SEDClient()\r\nsed.init()\r\nsed.build()\r\n\r\n# Simple queries using environment variables\r\nopenai_result = sed.query_with_openai(\"Analyze customer retention patterns\")\r\nclaude_result = sed.query_with_anthropic(\"Identify revenue optimization opportunities\")\r\n\r\nprint(f\"OpenAI Analysis: {openai_result['ai_enhancement']['ai_response']}\")\r\nprint(f\"Claude Analysis: {claude_result['ai_enhancement']['ai_response']}\")\r\n```\r\n\r\n### **OpenAI Integration (Manual)**\r\n```python\r\nimport openai\r\nfrom sedql import SEDClient\r\n\r\n# Initialize SED\r\nsed = SEDClient()\r\nsed.init()\r\nsed.build()\r\n\r\n# Set up OpenAI client\r\nopenai_client = openai.OpenAI(api_key=\"your-openai-api-key\")\r\n\r\n# Query with AI enhancement\r\nresult = sed.query_with_ai({\r\n    \"natural_language\": \"Analyze customer retention patterns\",\r\n    \"ai_client\": openai_client,\r\n    \"ai_service\": \"custom\",\r\n    \"ai_model\": \"gpt-4\"\r\n})\r\n\r\nprint(f\"AI Analysis: {result['ai_enhancement']['ai_response']}\")\r\n```\r\n\r\n### **Anthropic Integration (Manual)**\r\n```python\r\nimport anthropic\r\nfrom sedql import SEDClient\r\n\r\n# Initialize SED\r\nsed = SEDClient()\r\nsed.init()\r\nsed.build()\r\n\r\n# Set up Anthropic client\r\nanthropic_client = anthropic.Anthropic(api_key=\"your-anthropic-api-key\")\r\n\r\n# Query with AI enhancement\r\nresult = sed.query_with_ai({\r\n    \"natural_language\": \"Identify revenue optimization opportunities\",\r\n    \"ai_client\": anthropic_client,\r\n    \"ai_service\": \"custom\",\r\n    \"ai_model\": \"claude-3-sonnet-20240229\"\r\n})\r\n\r\nprint(f\"AI Analysis: {result['ai_enhancement']['ai_response']}\")\r\n```\r\n\r\n### **Custom AI Service Integration**\r\n```python\r\nfrom sedql import SEDClient\r\n\r\n# Your custom AI service\r\nclass CustomAIService:\r\n    def generate(self, prompt, max_tokens=1000):\r\n        # Your AI logic here\r\n        return f\"AI analysis: {prompt[:50]}...\"\r\n\r\n# Initialize SED\r\nsed = SEDClient()\r\nsed.init()\r\nsed.build()\r\n\r\n# Use your custom AI service\r\ncustom_ai = CustomAIService()\r\n\r\nresult = sed.query_with_ai({\r\n    \"natural_language\": \"Forecast sales for next quarter\",\r\n    \"ai_client\": custom_ai,\r\n    \"ai_model\": \"custom-model\"\r\n})\r\n\r\nprint(f\"Custom AI Analysis: {result['ai_enhancement']['ai_response']}\")\r\n```\r\n\r\n## \ud83d\udccb Requirements\r\n\r\n- **Python**: 3.8+\r\n- **SED CLI**: `npm install -g sed-cli` (provides all the advanced features)\r\n- **Database**: PostgreSQL, MySQL, SQLite (handled by CLI config)\r\n- **AI Services**: Install your preferred AI provider packages as needed\r\n\r\n## \ud83d\udd27 Installation\r\n\r\n### 1. Install SED CLI (Required)\r\n```bash\r\nnpm install -g sed-cli\r\n```\r\n\r\n### 2. Install Python Package\r\n```bash\r\npip install sedql\r\n```\r\n\r\n### 3. Set Up AI API Keys (Optional but Recommended)\r\n```bash\r\n# For OpenAI\r\nexport OPENAI_API_KEY=\"your-openai-api-key-here\"\r\n\r\n# For Anthropic\r\nexport ANTHROPIC_API_KEY=\"your-anthropic-api-key-here\"\r\n\r\n# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.) to make permanent\r\necho 'export OPENAI_API_KEY=\"your-key\"' >> ~/.bashrc\r\necho 'export ANTHROPIC_API_KEY=\"your-key\"' >> ~/.bashrc\r\n```\r\n\r\n### 4. Verify Setup\r\n```python\r\nfrom sedql import SEDClient\r\n\r\n# Check what AI services are available\r\nsed = SEDClient()\r\nstatus = sed.get_ai_environment_status()\r\nprint(f\"Available AI services: {status['available_services']}\")\r\n```\r\n\r\n## \ud83c\udfaf API Reference\r\n\r\n### SEDClient\r\n\r\nMain client class that provides full access to SED CLI capabilities.\r\n\r\n#### Core Methods\r\n- `init(force=False)` - Initialize SED with database connection\r\n- `build(output_file=None)` - Build or rebuild semantic layer\r\n- `query(natural_language_query, verbose=False)` - Query database using natural language\r\n- `query_with_ai(query_params)` - Query with AI integration and full SED features\r\n\r\n#### Advanced Features\r\n- `detect_changes(format=\"json\")` - Detect schema changes with analysis\r\n- `get_status()` - Get current SED status with business rules\r\n- `export_config(format=\"json\", output_file=None)` - Export configuration\r\n- `validate()` - Validate semantic layer and business rules\r\n- `get_semantic_mapping()` - Get business entities and relationships\r\n\r\n## \ud83c\udfaf Use Cases\r\n\r\n- **Data Engineering**: Programmatically build semantic layers\r\n- **Data Science**: Query databases using natural language with AI\r\n- **Application Integration**: Embed SED functionality in Python apps\r\n- **Automation**: Script database discovery and mapping\r\n- **AI Development**: Provide semantic context to LLMs\r\n- **Data Governance**: Automatic PII protection and compliance\r\n\r\n## \ud83d\udd0d Examples\r\n\r\n### Enhanced Query with AI\r\n```python\r\nfrom sedql import SEDClient\r\n\r\n# Create enhanced client\r\nsed = SEDClient()\r\n\r\n# Execute AI-enhanced query with full SED features\r\nresponse = sed.query_with_ai({\r\n    \"natural_language\": \"Show me customer retention trends\",\r\n    \"ai_model\": \"gpt-4\",\r\n    \"business_context\": \"Customer analytics and retention analysis\"\r\n})\r\n\r\n# Access all the rich features\r\nprint(\"\ud83c\udfaf Query Results:\")\r\nprint(f\"   Data: {response['query_result']}\")\r\n\r\nprint(\"\ud83d\udd12 Security & Compliance:\")\r\nprint(f\"   Risk Level: {response['risk_assessment']['risk_level']}\")\r\nprint(f\"   Validation: {response['validation']}\")\r\n\r\nprint(\"\ud83d\udcbc Business Intelligence:\")\r\nprint(f\"   Context: {response['business_context']}\")\r\nprint(f\"   Insights: {response['insights']}\")\r\n```\r\n\r\n### Business Rules and Validation\r\n```python\r\n# Get current status with business rules\r\nstatus = sed.get_status()\r\nprint(f\"Business Rules: {status.get('rules', {})}\")\r\n\r\n# Validate semantic layer\r\nvalidation = sed.validate()\r\nprint(f\"Validation Status: {validation.get('summary', {}).get('status')}\")\r\n\r\n# Detect schema changes\r\nchanges = sed.detect_changes(format=\"json\")\r\nprint(f\"Total Changes: {changes.get('analysis', {}).get('total_changes', 0)}\")\r\n```\r\n\r\n## \ud83c\udf1f Why SEDQL Python SDK?\r\n\r\n### **Full CLI Power in Python**\r\n- Access to all `sed-cli` features from Python\r\n- Business rules engine and validation\r\n- Schema change detection and analysis\r\n- Rich response processing and insights\r\n\r\n### **Enterprise Ready**\r\n- Local-first architecture (no data leaves your machine)\r\n- Automatic PII protection and compliance\r\n- Business rule generation and enforcement\r\n- Professional-grade security and audit trails\r\n\r\n### **AI Integration Ready**\r\n- Semantic layer for LLM context\r\n- Business terminology mapping\r\n- Risk assessment and validation\r\n- Custom AI client integration\r\n\r\n## \ud83c\udfaf How AI Integration Works\r\n\r\n### **SED's Role (What We Provide)**\r\n- \ud83d\udd12 **Security & Governance**: Business rules, PII protection, access control\r\n- \ud83c\udfd7\ufe0f **Business Context**: Semantic layer, entity relationships, business logic\r\n- \u2705 **Query Validation**: Ensures AI requests are safe and compliant\r\n- \ud83d\udcca **Data Access**: Secure database queries with business rule enforcement\r\n- \ud83d\udeab **Risk Assessment**: Evaluates query safety before execution\r\n\r\n### **Your Role (What You Provide)**\r\n- \ud83e\udd16 **AI Service**: OpenAI, Anthropic, or your custom AI service\r\n- \ud83d\udd11 **API Keys**: Your credentials for the AI service\r\n- \ud83c\udf9b\ufe0f **Model Selection**: Which AI model to use (GPT-4, Claude, etc.)\r\n- \ud83d\udcb0 **Cost Management**: You control your AI service usage and costs\r\n\r\n### **The Integration Flow**\r\n1. **You ask a question** \u2192 \"Analyze customer retention patterns\"\r\n2. **SED provides context** \u2192 Business entities, relationships, security rules\r\n3. **SED validates the request** \u2192 Checks business rules and security policies\r\n4. **SED executes the query** \u2192 Gets data safely from your database\r\n5. **Your AI service analyzes** \u2192 Processes the data and provides insights\r\n6. **SED returns everything** \u2192 Query results + AI analysis + security context\r\n\r\n### **Why This Approach?**\r\n- \u2705 **No vendor lock-in**: Use any AI service you prefer\r\n- \u2705 **Cost control**: You manage your AI service costs\r\n- \u2705 **Security**: SED handles data governance, AI handles analysis\r\n- \u2705 **Flexibility**: Switch between AI providers as needed\r\n- \u2705 **Compliance**: Business rules are enforced regardless of AI service\r\n\r\n## \ud83d\udd17 Related Projects\r\n\r\n- **[sed-cli](https://www.npmjs.com/package/sed-cli)** - Core TypeScript CLI (npm package)\r\n- **[GitHub Repository](https://github.com/holy182/sed-cli)** - Source code and documentation\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the GNU Affero General Public License v3.0 - see the [LICENSE](https://github.com/holy182/sed-cli/blob/main/LICENSE) file for details.\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nWe welcome contributions! Please see our [Contributing Guidelines](https://github.com/holy182/sed-cli/blob/main/CONTRIBUTING.md) for details.\r\n\r\n---\r\n\r\n**Built with \u2764\ufe0f by the SED Team**\r\n\r\n## \ud83d\udd12 Security & API Key Management\r\n\r\n### **Best Practices for API Keys**\r\n- \u2705 **Use environment variables** - Never hardcode API keys in your code\r\n- \u2705 **Use .env files** - For local development (add .env to .gitignore)\r\n- \u2705 **Use secret management** - For production deployments\r\n- \u2705 **Rotate keys regularly** - Keep your API keys secure\r\n\r\n### **Environment Variable Setup**\r\n```bash\r\n# Local development (.env file)\r\necho \"OPENAI_API_KEY=your-key-here\" > .env\r\necho \"ANTHROPIC_API_KEY=your-key-here\" >> .env\r\n\r\n# Production (set in your deployment environment)\r\nexport OPENAI_API_KEY=\"your-production-key\"\r\nexport ANTHROPIC_API_KEY=\"your-production-key\"\r\n```\r\n\r\n### **What SED Does NOT Do**\r\n- \u274c **Store API keys** - We never see or store your credentials\r\n- \u274c **Make external calls** - All AI calls go through your environment\r\n- \u274c **Track usage** - We don't monitor your AI service usage\r\n- \u274c **Share data** - Your data stays local, AI calls go to your provider\r\n\r\n### **What SED DOES Do**\r\n- \u2705 **Provide security** - Business rules, PII protection, access control\r\n- \u2705 **Validate queries** - Ensure AI requests are safe and compliant\r\n- \u2705 **Manage context** - Provide business intelligence and semantic mapping\r\n- \u2705 **Enforce governance** - Apply your company's data policies\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python SDK for SED (Semantic Entities Designs) - Full TypeScript CLI Integration",
    "version": "1.0.10",
    "project_urls": {
        "Bug Tracker": "https://github.com/holy182/sed-cli/issues",
        "Documentation": "https://github.com/holy182/sed-cli#readme",
        "Homepage": "https://github.com/holy182/sed-cli",
        "Repository": "https://github.com/holy182/sed-cli"
    },
    "split_keywords": [
        "semantic",
        " database",
        " ai",
        " dsl",
        " data-modeling",
        " automation",
        " sed",
        " cli"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e7b4f9adc7bf25085d279ea5b234a031c7eb5b1e501196fd0adef2c9c920ac69",
                "md5": "802627b7729fe62abf77044c9e1234c6",
                "sha256": "34c637196ef3c2a52004b615f7e57e358ba1501b7c94cb5fe07c997ed3eac48d"
            },
            "downloads": -1,
            "filename": "sedql-1.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "802627b7729fe62abf77044c9e1234c6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13978,
            "upload_time": "2025-08-15T17:11:40",
            "upload_time_iso_8601": "2025-08-15T17:11:40.772963Z",
            "url": "https://files.pythonhosted.org/packages/e7/b4/f9adc7bf25085d279ea5b234a031c7eb5b1e501196fd0adef2c9c920ac69/sedql-1.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d1a75cc62d76d5696191d03163d2442d76ca092fd575bb357231ea592861e6d8",
                "md5": "5725c1afb132df2ed68ce6c1ff0ac858",
                "sha256": "7cb71983659cd831d43fb08c78c1db51c45f765a8a4c81e85a9f55d44f68e719"
            },
            "downloads": -1,
            "filename": "sedql-1.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "5725c1afb132df2ed68ce6c1ff0ac858",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 19021,
            "upload_time": "2025-08-15T17:11:42",
            "upload_time_iso_8601": "2025-08-15T17:11:42.161559Z",
            "url": "https://files.pythonhosted.org/packages/d1/a7/5cc62d76d5696191d03163d2442d76ca092fd575bb357231ea592861e6d8/sedql-1.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 17:11:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "holy182",
    "github_project": "sed-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sedql"
}
        
Elapsed time: 1.45578s