Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added docs/data-sources/mssql.mdx
Empty file.
1 change: 1 addition & 0 deletions docs/data-sources/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Embedchain comes with built-in support for various data sources. We handle the c
<Card title="🐬 MySQL" href="/data-sources/mysql"></Card>
<Card title="🤖 Slack" href="/data-sources/slack"></Card>
<Card title="🗨️ Discourse" href="/data-sources/discourse"></Card>
<Card title=" MSSQL" href="/data-sources/mssql"></Card>
</CardGroup>

<br/ >
Expand Down
37 changes: 37 additions & 0 deletions embedchain/loaders/mssql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from typing import Optional, Dict, Any
from embedchain.loaders.base_loader import BaseLoader

class MSSQLLoader(BaseLoader):
"""Loader for MSSQL data."""

def __init__(self, config: Optional[Dict[str, Any]]):
super().__init__()
if not config:
raise ValueError(
f"Invalid MSSQL config: {config}.",
"Provide the correct config, refer `https://docs.embedchain.ai/data-sources/mssql`.",
)

self.config = config
self.connection = None
self.cursor = None
self._setup_loader(config=config)

def _setup_loader(self, config: Dict[str, Any]):
try:
import pyodbc
except ImportError as e:
raise ImportError(
"Unable to import required packages for MSSQL loader. Run `pip install --upgrade 'embedchain[mssql]'`." # noqa: E501
) from e

try:
self.connection = pyodbc.connect(**config)
self.cursor = self.connection.cursor()
except Exception as e:
raise ValueError(
f"Unable to connect to MSSQL server with the given config: {config}.", # noqa: E501
)

def load_data():
pass
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ psycopg = { version = "^3.1.12", optional = true }
psycopg-binary = { version = "^3.1.12", optional = true }
psycopg-pool = { version = "^3.1.8", optional = true }
mysql-connector-python = { version = "^8.1.0", optional = true }
pyodbc = { version = "4.0.34", optional = true }

[tool.poetry.group.dev.dependencies]
black = "^23.3.0"
Expand Down Expand Up @@ -190,6 +191,7 @@ gmail = [
json = ["llama-hub"]
postgres = ["psycopg", "psycopg-binary", "psycopg-pool"]
mysql = ["mysql-connector-python"]
mssql = ["pyodbc"]

[tool.poetry.group.docs.dependencies]

Expand Down