Skip to content

Commit 2644e2d

Browse files
Fix postgresql (#155)
1 parent d5040cf commit 2644e2d

File tree

12 files changed

+153
-151
lines changed

12 files changed

+153
-151
lines changed

deploy_ai_search_indexes/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ snowflake = [
3737
databricks = [
3838
"text_2_sql_core[databricks]",
3939
]
40-
postgresql = [
41-
"text_2_sql_core[postgresql]",
40+
postgres = [
41+
"text_2_sql_core[postgres]",
4242
]
4343
sqlite = [
4444
"text_2_sql_core[sqlite]",

image_processing/src/image_processing/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ beautifulsoup4==4.12.3
2020
blis==0.7.11
2121
bs4==0.0.2
2222
catalogue==2.0.10
23-
certifi==2024.12.14
23+
certifi==2025.1.31
2424
cffi==1.17.1 ; platform_python_implementation != 'PyPy'
2525
charset-normalizer==3.4.1
2626
click==8.1.8
@@ -38,7 +38,7 @@ fsspec==2024.12.0
3838
h11==0.14.0
3939
httpcore==1.0.7
4040
httpx==0.28.1
41-
huggingface-hub==0.28.0
41+
huggingface-hub==0.28.1
4242
idna==3.10
4343
isodate==0.7.2
4444
jinja2==3.1.5
@@ -74,7 +74,7 @@ pyjwt==2.10.1
7474
pymupdf==1.25.2
7575
python-dateutil==2.9.0.post0
7676
python-dotenv==1.0.1
77-
pytz==2024.2
77+
pytz==2025.1
7878
pywin32==308 ; sys_platform == 'win32'
7979
pyyaml==6.0.2
8080
regex==2024.11.6

text_2_sql/.env.example

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Environment variables for Text2SQL
22
IdentityType=<identityType> # system_assigned or user_assigned or key
33

4-
Text2Sql__DatabaseEngine=<DatabaseEngine> # TSQL or PostgreSQL or Snowflake or Databricks
4+
Text2Sql__DatabaseEngine=<DatabaseEngine> # TSQL or Postgres or Snowflake or Databricks
55
Text2Sql__UseQueryCache=<Determines if the Query Cache will be used to speed up query generation. Defaults to True.> # True or False
66
Text2Sql__PreRunQueryCache=<Determines if the results from the Query Cache will be pre-run to speed up answer generation. Defaults to True.> # True or False
77
Text2Sql__UseColumnValueStore=<Determines if the Column Value Store will be used for schema selection Defaults to True.> # True or False
@@ -26,13 +26,13 @@ AIService__AzureSearchOptions__Text2SqlColumnValueStore__Index=<Column value sto
2626
Text2Sql__Tsql__ConnectionString=<Tsql databaseConnectionString if using Tsql Data Source>
2727
Text2Sql__Tsql__Database=<Tsql database if using Tsql Data Source>
2828

29-
# PostgreSQL Specific Connection Details
30-
Text2Sql__Postgresql__ConnectionString=<Postgresql databaseConnectionString if using Postgresql Data Source and a connection string>
31-
Text2Sql__Postgresql__Database=<Postgresql database if using Postgresql Data Source>
32-
Text2Sql__Postgresql__User=<Postgresql user if using Postgresql Data Source and not the connections string>
33-
Text2Sql__Postgresql__Password=<Postgresql password if using Postgresql Data Source and not the connections string>
34-
Text2Sql__Postgresql__ServerHostname=<Postgresql serverHostname if using Postgresql Data Source and not the connections string>
35-
Text2Sql__Postgresql__Port=<Postgresql port if using Postgresql Data Source and not the connections string>
29+
# Postgres Specific Connection Details
30+
Text2Sql__Postgres__ConnectionString=<Postgres databaseConnectionString if using Postgres Data Source and a connection string>
31+
Text2Sql__Postgres__Database=<Postgres database if using Postgres Data Source>
32+
Text2Sql__Postgres__User=<Postgres user if using Postgres Data Source and not the connections string>
33+
Text2Sql__Postgres__Password=<Postgres password if using Postgres Data Source and not the connections string>
34+
Text2Sql__Postgres__ServerHostname=<Postgres serverHostname if using Postgres Data Source and not the connections string>
35+
Text2Sql__Postgres__Port=<Postgres port if using Postgres Data Source and not the connections string>
3636

3737
# Snowflake Specific Connection Details
3838
Text2Sql__Snowflake__User=<snowflakeUser if using Snowflake Data Source>

text_2_sql/autogen/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ snowflake = [
4242
databricks = [
4343
"text_2_sql_core[databricks]",
4444
]
45-
postgresql = [
46-
"text_2_sql_core[postgresql]",
45+
postgres = [
46+
"text_2_sql_core[postgres]",
4747
]
4848
sqlite = [
4949
"text_2_sql_core[sqlite]",

text_2_sql/data_dictionary/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ The following Databases have pre-built scripts for them:
218218
- **Databricks:** `./text_2_sql_core/data_dictionary/databricks_data_dictionary_creator.py`
219219
- **Snowflake:** `./text_2_sql_core/data_dictionary/snowflake_data_dictionary_creator.py`
220220
- **TSQL:** `./text_2_sql_core/data_dictionary/tsql_data_dictionary_creator.py`
221-
- **PostgreSQL:** `./text_2_sql_core/data_dictionary/postgresql_data_dictionary_creator.py`
221+
- **Postgres:** `./text_2_sql_core/data_dictionary/postgres_data_dictionary_creator.py`
222222

223223
If there is no pre-built script for your database engine, take one of the above as a starting point and adjust it.
224224

text_2_sql/text_2_sql_core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ databricks = [
4747
"databricks-sql-connector>=3.0.1",
4848
"pyarrow>=14.0.2,<17",
4949
]
50-
postgresql = [
50+
postgres = [
5151
"psycopg>=3.2.3",
5252
]
5353
sqlite = [

text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/factory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ def get_database_connector():
2525
from text_2_sql_core.connectors.tsql_sql import TsqlSqlConnector
2626

2727
return TsqlSqlConnector()
28-
elif os.environ["Text2Sql__DatabaseEngine"].upper() == "POSTGRESQL":
29-
from text_2_sql_core.connectors.postgresql_sql import (
30-
PostgresqlSqlConnector,
28+
elif os.environ["Text2Sql__DatabaseEngine"].upper() == "POSTGRES":
29+
from text_2_sql_core.connectors.postgres_sql import (
30+
PostgresSqlConnector,
3131
)
3232

33-
return PostgresqlSqlConnector()
33+
return PostgresSqlConnector()
3434
elif os.environ["Text2Sql__DatabaseEngine"].upper() == "SQLITE":
3535
from text_2_sql_core.connectors.sqlite_sql import SQLiteSqlConnector
3636

text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/postgresql_sql.py renamed to text_2_sql/text_2_sql_core/src/text_2_sql_core/connectors/postgres_sql.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
from text_2_sql_core.utils.database import DatabaseEngine, DatabaseEngineSpecificFields
1111

1212

13-
class PostgresqlSqlConnector(SqlConnector):
13+
class PostgresSqlConnector(SqlConnector):
1414
def __init__(self):
1515
super().__init__()
1616

17-
self.database_engine = DatabaseEngine.POSTGRESQL
17+
self.database_engine = DatabaseEngine.POSTGRES
1818

1919
@property
2020
def engine_specific_rules(self) -> str:
@@ -54,7 +54,7 @@ async def query_execution(
5454
cast_to: any = None,
5555
limit=None,
5656
) -> list[dict]:
57-
"""Run the SQL query against the PostgreSQL database asynchronously.
57+
"""Run the SQL query against the Postgres database asynchronously.
5858
5959
Args:
6060
----
@@ -67,10 +67,10 @@ async def query_execution(
6767
logging.info(f"Running query: {sql_query}")
6868
results = []
6969

70-
if "Text2Sql__Postgresql__ConnectionString" in os.environ:
71-
logging.info("Postgresql Connection string found in environment variables.")
70+
if "Text2Sql__Postgres__ConnectionString" in os.environ:
71+
logging.info("Postgres Connection string found in environment variables.")
7272

73-
p = urlparse(os.environ["Text2Sql__Postgresql__ConnectionString"])
73+
p = urlparse(os.environ["Text2Sql__Postgres__ConnectionString"])
7474

7575
postgres_connections = {
7676
"dbname": p.path[1:],
@@ -81,17 +81,17 @@ async def query_execution(
8181
}
8282
else:
8383
logging.warning(
84-
"Postgresql Connection string not found in environment variables. Using individual variables."
84+
"Postgres Connection string not found in environment variables. Using individual variables."
8585
)
8686
postgres_connections = {
87-
"dbname": os.environ["Text2Sql__Postgresql__Database"],
88-
"user": os.environ["Text2Sql__Postgresql__User"],
89-
"password": os.environ["Text2Sql__Postgresql__Password"],
90-
"port": os.environ["Text2Sql__Postgresql__Port"],
91-
"host": os.environ["Text2Sql__Postgresql__ServerHostname"],
87+
"dbname": os.environ["Text2Sql__Postgres__Database"],
88+
"user": os.environ["Text2Sql__Postgres__User"],
89+
"password": os.environ["Text2Sql__Postgres__Password"],
90+
"port": os.environ["Text2Sql__Postgres__Port"],
91+
"host": os.environ["Text2Sql__Postgres__ServerHostname"],
9292
}
9393

94-
# Establish an asynchronous connection to the PostgreSQL database
94+
# Establish an asynchronous connection to the Postgres database
9595
async with await psycopg.AsyncConnection.connect(
9696
**postgres_connections
9797
) as conn:

text_2_sql/text_2_sql_core/src/text_2_sql_core/data_dictionary/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ def create(
9191
data_dictionary_creator = TsqlDataDictionaryCreator(
9292
**kwargs,
9393
)
94-
elif engine == DatabaseEngine.POSTGRESQL:
95-
from text_2_sql_core.data_dictionary.postgresql_data_dictionary_creator import (
96-
PostgresqlDataDictionaryCreator,
94+
elif engine == DatabaseEngine.POSTGRES:
95+
from text_2_sql_core.data_dictionary.postgres_data_dictionary_creator import (
96+
PostgresDataDictionaryCreator,
9797
)
9898

99-
data_dictionary_creator = PostgresqlDataDictionaryCreator(
99+
data_dictionary_creator = PostgresDataDictionaryCreator(
100100
**kwargs,
101101
)
102102
else:
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88
import os
99

1010
from text_2_sql_core.utils.database import DatabaseEngine
11-
from text_2_sql_core.connectors.postgresql_sql import PostgresqlSqlConnector
11+
from text_2_sql_core.connectors.postgres_sql import PostgresSqlConnector
1212

1313

14-
class PostgresqlDataDictionaryCreator(DataDictionaryCreator):
14+
class PostgresDataDictionaryCreator(DataDictionaryCreator):
1515
def __init__(self, **kwargs):
1616
"""A method to initialize the DataDictionaryCreator class."""
1717
excluded_schemas = ["information_schema", "pg_catalog"]
1818
super().__init__(excluded_schemas=excluded_schemas, **kwargs)
1919

20-
self.database = os.environ["Text2Sql__Postgresql__Database"]
21-
self.database_engine = DatabaseEngine.POSTGRESQL
20+
self.database = os.environ["Text2Sql__Postgres__Database"]
21+
self.database_engine = DatabaseEngine.POSTGRES
2222

23-
self.sql_connector = PostgresqlSqlConnector()
23+
self.sql_connector = PostgresSqlConnector()
2424

2525
@property
2626
def extract_table_entities_sql_query(self) -> str:
27-
"""A property to extract table entities from a PostgreSQL database."""
27+
"""A property to extract table entities from a Postgres database."""
2828
return """SELECT
2929
t.table_name AS "Entity",
3030
t.table_schema AS "EntitySchema",
@@ -46,7 +46,7 @@ def extract_table_entities_sql_query(self) -> str:
4646

4747
@property
4848
def extract_view_entities_sql_query(self) -> str:
49-
"""A property to extract view entities from a PostgreSQL database."""
49+
"""A property to extract view entities from a Postgres database."""
5050
return """SELECT
5151
v.table_name AS "Entity",
5252
v.table_schema AS "EntitySchema",
@@ -65,7 +65,7 @@ def extract_view_entities_sql_query(self) -> str:
6565
"EntitySchema", "Entity";"""
6666

6767
def extract_columns_sql_query(self, entity: EntityItem) -> str:
68-
"""A property to extract column information from a PostgreSQL database."""
68+
"""A property to extract column information from a Postgres database."""
6969
return f"""SELECT
7070
c.attname AS "Name",
7171
t.typname AS "DataType",
@@ -89,7 +89,7 @@ def extract_columns_sql_query(self, entity: EntityItem) -> str:
8989

9090
@property
9191
def extract_entity_relationships_sql_query(self) -> str:
92-
"""A property to extract entity relationships from a PostgreSQL database."""
92+
"""A property to extract entity relationships from a Postgres database."""
9393
return """SELECT
9494
fk_schema.nspname AS "EntitySchema",
9595
fk_tab.relname AS "Entity",
@@ -116,5 +116,5 @@ def extract_entity_relationships_sql_query(self) -> str:
116116

117117

118118
if __name__ == "__main__":
119-
data_dictionary_creator = PostgresqlDataDictionaryCreator()
119+
data_dictionary_creator = PostgresDataDictionaryCreator()
120120
asyncio.run(data_dictionary_creator.create_data_dictionary())

0 commit comments

Comments
 (0)