-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make all the connectors an extension
- Loading branch information
Showing
66 changed files
with
3,948 additions
and
1,956 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SQL Extension for PandasAI | ||
|
||
This extension integrates SQL connectors with PandasAI, providing support for various SQL databases (mysql, postgres, cockroachdb, sqlite). | ||
|
||
## Installation | ||
|
||
You can install this extension using poetry: | ||
|
||
```bash | ||
poetry install pandasai-sql | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from .sql import SQLConnector, SqliteConnector, SQLConnectorConfig | ||
import importlib | ||
|
||
|
||
def load_from_mysql(connection_info, query): | ||
pymysql = importlib.import_module("pymysql") | ||
pd = importlib.import_module("pandas") | ||
|
||
conn = pymysql.connect( | ||
host=connection_info["host"], | ||
user=connection_info["user"], | ||
password=connection_info["password"], | ||
database=connection_info["database"], | ||
port=connection_info["port"], | ||
) | ||
return pd.read_sql(query, conn) | ||
|
||
|
||
def load_from_postgres(connection_info, query): | ||
psycopg2 = importlib.import_module("psycopg2") | ||
pd = importlib.import_module("pandas") | ||
conn = psycopg2.connect( | ||
host=connection_info["host"], | ||
user=connection_info["user"], | ||
password=connection_info["password"], | ||
dbname=connection_info["database"], | ||
port=connection_info["port"], | ||
) | ||
return pd.read_sql(query, conn) | ||
|
||
|
||
__all__ = [ | ||
"SQLConnector", | ||
"SqliteConnector", | ||
"SQLConnectorConfig", | ||
"load_from_mysql", | ||
"load_from_postgres", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.