Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(data-warehouse): use sql alchemy format for executing queries #23927

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading