Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7cc999c

Browse files
committedMar 11, 2025
nvac removed
1 parent 2ed2f1a commit 7cc999c

File tree

4 files changed

+7
-31
lines changed

4 files changed

+7
-31
lines changed
 

‎src/providers/bigquery_provider.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def __init__(self, project_id: str, credentials_path: Optional[str] = None):
1313
)
1414
self.client = bigquery.Client(project=project_id, credentials=credentials)
1515
else:
16-
# Use default credentials
1716
self.client = bigquery.Client(project=project_id)
1817

1918
def execute_query(self, sql_query: str) -> List[Dict[str, Any]]:

‎src/providers/mysql_provider.py

-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def __init__(
1717
self.database = database
1818
self.port = port
1919
try:
20-
# Use MySQLConnectionAbstract as the base type for the union
2120
self.connection: (
2221
MySQLConnection | PooledMySQLConnection | MySQLConnectionAbstract
2322
) = mysql.connector.connect(
@@ -33,7 +32,6 @@ def __init__(
3332
def execute_query(self, sql_query: str) -> List[Dict[str, Any]]:
3433
cursor = self.connection.cursor(dictionary=True)
3534
cursor.execute(sql_query)
36-
# Cast the result to List[Dict[str, Any]] since dictionary=True ensures dicts
3735
results = cast(List[Dict[str, Any]], cursor.fetchall())
3836
cursor.close()
3937
return results
@@ -94,7 +92,6 @@ def get_compact_tables(
9492
""",
9593
(schema_name,),
9694
)
97-
# Cast to List[Dict[str, str]] since dictionary=True ensures dicts
9895
results = cast(List[Dict[str, str]], cursor.fetchall())
9996
if not results:
10097
raise Exception(f"No tables found in schema '{schema_name}'")
@@ -115,7 +112,6 @@ def get_compact_tables(
115112
""",
116113
(schema_name, table_name),
117114
)
118-
# Cast to List[Dict[str, str]] since dictionary=True ensures dicts
119115
columns = cast(List[Dict[str, str]], cursor.fetchall())
120116

121117
cursor.execute(
@@ -126,7 +122,6 @@ def get_compact_tables(
126122
""",
127123
(schema_name, table_name),
128124
)
129-
# Cast to Optional[Dict[str, str]] since dictionary=True ensures dict or None
130125
description_row = cast(Optional[Dict[str, str]], cursor.fetchone())
131126
table_description = (
132127
description_row["description"]

‎src/providers/postgres_provider.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def get_compact_tables(
9090
"""
9191
cursor = self.connection.cursor()
9292

93-
# Get all tables if table_names is None
9493
if table_names is None:
9594
cursor.execute(
9695
"""
@@ -106,7 +105,6 @@ def get_compact_tables(
106105
compact_tables = []
107106

108107
for table_name in table_names:
109-
# Get column information
110108
cursor.execute(
111109
"""
112110
SELECT column_name, data_type, is_nullable
@@ -118,7 +116,6 @@ def get_compact_tables(
118116
)
119117
columns = cursor.fetchall()
120118

121-
# Get table description if available
122119
cursor.execute(
123120
"""
124121
SELECT obj_description(
@@ -137,10 +134,7 @@ def get_compact_tables(
137134
col_name = column[0]
138135
col_type = column[1].lower()
139136

140-
# Map the PostgreSQL type to our compact type
141-
mapped_type = type_map.get(
142-
col_type, "S"
143-
) # Default to string if type not found
137+
mapped_type = type_map.get(col_type, "S")
144138
fields.append({"n": col_name, "t": mapped_type})
145139

146140
compact_tables.append(

‎src/providers/sqlite_provider.py

+6-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def __init__(self, database_path: str):
1414
"""
1515
self.database_path = database_path
1616
self.connection = sqlite3.connect(database_path)
17-
# Enable dictionary access to rows
1817
self.connection.row_factory = sqlite3.Row
1918

2019
def execute_query(self, sql_query: str) -> List[Dict[str, Any]]:
@@ -71,7 +70,6 @@ def get_compact_tables(
7170
"""
7271
cursor = self.connection.cursor()
7372

74-
# Get all tables if table_names is None
7573
if table_names is None:
7674
cursor.execute(
7775
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"
@@ -82,32 +80,22 @@ def get_compact_tables(
8280
compact_tables = []
8381

8482
for table_name in table_names:
85-
# Get table info
8683
cursor.execute(f"PRAGMA table_info('{table_name}')")
8784
columns = cursor.fetchall()
8885

89-
# Debug: Print raw column data to see what we're getting
90-
print(f"Table: {table_name}, Columns: {columns}")
91-
9286
fields = []
9387
for column in columns:
94-
# PRAGMA table_info returns: (cid, name, type, notnull, dflt_value, pk)
95-
col_name = column[1] # name is at index 1
96-
col_type = (
97-
column[2].upper() if column[2] else "TEXT"
98-
) # type is at index 2
99-
100-
# Map the SQLite type to our compact type
101-
mapped_type = type_map.get(
102-
col_type, "S"
103-
) # Default to string if type not found
88+
col_name = column[1]
89+
col_type = column[2].upper() if column[2] else "TEXT"
90+
91+
mapped_type = type_map.get(col_type, "S")
92+
fields.append({"n": col_name, "t": mapped_type})
10493
fields.append({"n": col_name, "t": mapped_type})
10594

106-
# SQLite doesn't have schemas, so we just use the table name
10795
compact_tables.append(
10896
{
10997
"t": table_name,
110-
"d": "", # SQLite doesn't store table descriptions
98+
"d": "",
11199
"f": fields,
112100
}
113101
)

0 commit comments

Comments
 (0)
Please sign in to comment.