Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vgvoleg committed Nov 11, 2024
1 parent 04761ca commit 512b1eb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ydb_sqlalchemy/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ def _describe_table(self, connection, table_name, schema=None) -> ydb.TableDescr
except dbapi.DatabaseError as e:
raise NoSuchTableError(qt) from e

def get_view_names(self, connection, schema=None, **kw: Any):
return []

@reflection.cache
def get_columns(self, connection, table_name, schema=None, **kw):
table = self._describe_table(connection, table_name, schema)
Expand Down Expand Up @@ -849,7 +852,7 @@ def __merge_parameters_values_and_types(
result_list.append(result)
return result_list if execute_many else result_list[0]

def _make_ydb_operation(
def _prepare_ydb_query(
self,
statement: str,
context: Optional[DefaultExecutionContext] = None,
Expand All @@ -872,7 +875,7 @@ def _make_ydb_operation(

def do_ping(self, dbapi_connection: dbapi.Connection) -> bool:
cursor = dbapi_connection.cursor()
statement, _ = self._make_ydb_operation(self._dialect_specific_select_one)
statement, _ = self._prepare_ydb_query(self._dialect_specific_select_one)
try:
cursor.execute(statement)
finally:
Expand All @@ -886,7 +889,7 @@ def do_executemany(
parameters: Optional[Sequence[Mapping[str, Any]]],
context: Optional[DefaultExecutionContext] = None,
) -> None:
operation, parameters = self._make_ydb_operation(statement, context, parameters, execute_many=True)
operation, parameters = self._prepare_ydb_query(statement, context, parameters, execute_many=True)
cursor.executemany(operation, parameters)

def do_execute(
Expand All @@ -896,7 +899,7 @@ def do_execute(
parameters: Optional[Mapping[str, Any]] = None,
context: Optional[DefaultExecutionContext] = None,
) -> None:
operation, parameters = self._make_ydb_operation(statement, context, parameters, execute_many=False)
operation, parameters = self._prepare_ydb_query(statement, context, parameters, execute_many=False)
is_ddl = context.isddl if context is not None else False
if is_ddl:
cursor.execute_scheme(operation, parameters)
Expand Down

0 comments on commit 512b1eb

Please sign in to comment.