Appearance
Elsai DB
Package: elsai-db v0.2.0
Natural language queries over SQL databases — MySQL, PostgreSQL, and ODBC — powered by an LLM agent. Pass a plain English question; the connector translates it to SQL, runs it, and returns a human-readable answer.
Installation
bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-db/ elsai-db==0.2.0Requirements: Python >= 3.9
:::note v0.2.0 upgrades the LangChain dependency for improved compatibility and performance. :::
How it works
The connector inspects the database schema, asks the LLM to generate the appropriate SQL, executes it, then formats the raw result as a natural language answer.
Available connectors
| Class | Import path | Database |
|---|---|---|
MySQLSQLConnector | elsai_db.mysql | MySQL (native) |
PostgreSQLConnector | elsai_db.postgres | PostgreSQL (native) |
OdbcMysqlConnector | elsai_db.odbc_mysql | MySQL via ODBC |
OdbcPostgresqlConnector | elsai_db.odbc_postgres | PostgreSQL via ODBC |
MySQLSQLConnector
Connects to a MySQL database using a native driver and answers natural language questions via the LLM.
python
from elsai_db.mysql import MySQLSQLConnector
mysql_connector = MySQLSQLConnector(
llm="<elsai_model_instance>.client",
database_name="your_database_name",
database_password="your_database_password",
database_user="your_database_user",
database_url="your_database_url",
)
result = mysql_connector.invoke("what are the names of all employees?")
print(result)Parameters:
| Parameter | Description |
|---|---|
llm | LLM client from an Elsai model connector (e.g. AzureOpenAIConnector(...).client) |
database_name | Name of the MySQL database |
database_password | Database user password |
database_user | Database username |
database_url | Host or connection URL for the database server |
PostgreSQLConnector
Connects to a PostgreSQL database and answers natural language questions via the LLM.
python
from elsai_db.postgres import PostgreSQLConnector
postgres_connector = PostgreSQLConnector(
llm="<elsai_model_instance>.client",
database_name="your_database_name",
database_password="your_database_password",
database_user="your_database_user",
database_url="your_database_url",
)
result = postgres_connector.invoke("what are the names of all employees?")
print(result)Parameters:
| Parameter | Description |
|---|---|
llm | LLM client from an Elsai model connector |
database_name | Name of the PostgreSQL database |
database_password | Database user password |
database_user | Database username |
database_url | Host or connection URL for the database server |
OdbcMysqlConnector
Connects to a MySQL database via an ODBC driver. Use this when a native driver is unavailable or when connecting through a DSN.
python
from elsai_db.odbc_mysql import OdbcMysqlConnector
odbc_mysql_connector = OdbcMysqlConnector(
llm="<elsai_model_instance>.client",
database_name="your_database_name",
database_password="your_database_password",
database_user="your_database_user",
database_url="your_database_url",
driver_name="your_odbc_driver_name",
)
result = odbc_mysql_connector.invoke("what are the names of all employees?")
print(result)Parameters:
| Parameter | Description |
|---|---|
llm | LLM client from an Elsai model connector |
database_name | Name of the MySQL database |
database_password | Database user password |
database_user | Database username |
database_url | Host or connection URL for the database server |
driver_name | ODBC driver name as registered on the system (e.g. "MySQL ODBC 8.0 Unicode Driver") |
OdbcPostgresqlConnector
Connects to a PostgreSQL database via an ODBC driver.
python
from elsai_db.odbc_postgres import OdbcPostgresqlConnector
odbc_postgres_connector = OdbcPostgresqlConnector(
llm="<elsai_model_instance>.client",
database_name="your_database_name",
database_password="your_database_password",
database_user="your_database_user",
database_url="your_database_url",
driver_name="your_odbc_driver_name",
)
result = odbc_postgres_connector.invoke("what are the names of all employees?")
print(result)Parameters:
| Parameter | Description |
|---|---|
llm | LLM client from an Elsai model connector |
database_name | Name of the PostgreSQL database |
database_password | Database user password |
database_user | Database username |
database_url | Host or connection URL for the database server |
driver_name | ODBC driver name as registered on the system (e.g. "PostgreSQL Unicode") |
Version history
| Version | Changes |
|---|---|
| 0.2.0 | LangChain upgraded; improved compatibility |
| 0.1.0 | Initial release — MySQL, PostgreSQL, ODBC connectors |