From 8b98b67110ea6b617f807fc3584b7dc01f07ae2e Mon Sep 17 00:00:00 2001 From: Deven Patel Date: Wed, 15 Nov 2023 13:59:50 -0800 Subject: [PATCH 1/2] initial commit --- docs/data-sources/mssql.mdx | 0 docs/data-sources/overview.mdx | 1 + embedchain/loaders/mssql.py | 37 ++++++++++++++++++++++++++++++++++ pyproject.toml | 2 ++ 4 files changed, 40 insertions(+) create mode 100644 docs/data-sources/mssql.mdx create mode 100644 embedchain/loaders/mssql.py diff --git a/docs/data-sources/mssql.mdx b/docs/data-sources/mssql.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/data-sources/overview.mdx b/docs/data-sources/overview.mdx index 08b2a57229..bb5791addc 100644 --- a/docs/data-sources/overview.mdx +++ b/docs/data-sources/overview.mdx @@ -24,6 +24,7 @@ Embedchain comes with built-in support for various data sources. We handle the c +
diff --git a/embedchain/loaders/mssql.py b/embedchain/loaders/mssql.py new file mode 100644 index 0000000000..2540574573 --- /dev/null +++ b/embedchain/loaders/mssql.py @@ -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 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 933e61b81e..3871839fe7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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] From 0676a50351084ea9993d51c6e52f76579ba0026d Mon Sep 17 00:00:00 2001 From: "C.P" <137078450+toodeceptive@users.noreply.github.com> Date: Sat, 30 Dec 2023 09:53:46 +0000 Subject: [PATCH 2/2] Initial commit