Skip to content

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.0

Requirements: 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

ClassImport pathDatabase
MySQLSQLConnectorelsai_db.mysqlMySQL (native)
PostgreSQLConnectorelsai_db.postgresPostgreSQL (native)
OdbcMysqlConnectorelsai_db.odbc_mysqlMySQL via ODBC
OdbcPostgresqlConnectorelsai_db.odbc_postgresPostgreSQL 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:

ParameterDescription
llmLLM client from an Elsai model connector (e.g. AzureOpenAIConnector(...).client)
database_nameName of the MySQL database
database_passwordDatabase user password
database_userDatabase username
database_urlHost 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:

ParameterDescription
llmLLM client from an Elsai model connector
database_nameName of the PostgreSQL database
database_passwordDatabase user password
database_userDatabase username
database_urlHost 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:

ParameterDescription
llmLLM client from an Elsai model connector
database_nameName of the MySQL database
database_passwordDatabase user password
database_userDatabase username
database_urlHost or connection URL for the database server
driver_nameODBC 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:

ParameterDescription
llmLLM client from an Elsai model connector
database_nameName of the PostgreSQL database
database_passwordDatabase user password
database_userDatabase username
database_urlHost or connection URL for the database server
driver_nameODBC driver name as registered on the system (e.g. "PostgreSQL Unicode")

Version history

VersionChanges
0.2.0LangChain upgraded; improved compatibility
0.1.0Initial release — MySQL, PostgreSQL, ODBC connectors

Copyright © 2026 Elsai Foundry.