Skip to content

Commit

Permalink
chore(data-warehouse): use sql alchemy format for executing queries (P…
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE authored and silentninja committed Aug 8, 2024
1 parent c8aa7bb commit c9d2601
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions posthog/temporal/data_imports/pipelines/sql_database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from urllib.parse import quote

from posthog.warehouse.types import IncrementalFieldType
from sqlalchemy.sql import text

from .helpers import (
table_rows,
Expand Down Expand Up @@ -150,14 +151,13 @@ def sql_database(

def get_column_hints(engine: Engine, schema_name: str, table_name: str) -> dict[str, TColumnSchema]:
with engine.connect() as conn:
execute_result: CursorResult | None = conn.execute(
"SELECT column_name, data_type, numeric_precision, numeric_scale FROM information_schema.columns WHERE table_schema = %(schema_name)s AND table_name = %(table_name)s",
execute_result: CursorResult = conn.execute(
text(
"SELECT column_name, data_type, numeric_precision, numeric_scale FROM information_schema.columns WHERE table_schema = :schema_name AND table_name = :table_name"
),
{"schema_name": schema_name, "table_name": table_name},
)

if execute_result is None:
return {}

cursor_result = cast(CursorResult, execute_result)
results = cursor_result.fetchall()

Expand Down

0 comments on commit c9d2601

Please sign in to comment.