Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Commit 8e97d23

Browse files
committed
chores: using single quote
1 parent a6a475d commit 8e97d23

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

sqlalchemy_trino/dialect.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def get_rowcount(self):
3333
class TrinoDialect(DefaultDialect):
3434
name = 'trino'
3535
driver = 'rest'
36-
paramstyle = 'pyformat' # trino.dbapi.paramstyle
3736

3837
execution_ctx_cls = TrinoExecutionContext
3938
statement_compiler = compiler.TrinoSQLCompiler
@@ -47,7 +46,7 @@ class TrinoDialect(DefaultDialect):
4746
supports_native_decimal = True
4847

4948
# Column options
50-
supports_sequences = False # TODO: check
49+
supports_sequences = False
5150
supports_comments = True
5251
inline_comments = True
5352
supports_default_values = False
@@ -56,7 +55,7 @@ class TrinoDialect(DefaultDialect):
5655
supports_alter = True
5756

5857
# DML
59-
supports_empty_insert = False # TODO: check
58+
supports_empty_insert = False
6059
supports_multivalues_insert = True
6160

6261
@classmethod
@@ -91,13 +90,13 @@ def create_connect_args(self, url: URL) -> Tuple[List[Any], Dict[str, Any]]:
9190
def get_columns(self, connection: Connection,
9291
table_name: str, schema: str = None, **kw) -> List[Dict[str, Any]]:
9392
if not self.has_table(connection, table_name, schema):
94-
raise exc.NoSuchTableError(f"schema={schema}, table={table_name}")
93+
raise exc.NoSuchTableError(f'schema={schema}, table={table_name}')
9594
return self._get_columns(connection, table_name, schema, **kw)
9695

9796
def _get_columns(self, connection: Connection,
9897
table_name: str, schema: str = None, **kw) -> List[Dict[str, Any]]:
9998
schema = schema or self._get_default_schema_name(connection)
100-
query = dedent("""
99+
query = dedent('''
101100
SELECT
102101
"column_name",
103102
"column_default",
@@ -106,7 +105,7 @@ def _get_columns(self, connection: Connection,
106105
FROM "information_schema"."columns"
107106
WHERE "table_schema" = :schema AND "table_name" = :table
108107
ORDER BY "ordinal_position" ASC
109-
""").strip()
108+
''').strip()
110109
res = connection.execute(sql.text(query), schema=schema, table=table_name)
111110
columns = []
112111
for record in res:
@@ -135,14 +134,14 @@ def get_foreign_keys(self, connection: Connection,
135134
return []
136135

137136
def get_schema_names(self, connection: Connection, **kw) -> List[str]:
138-
query = "SHOW SCHEMAS"
137+
query = 'SHOW SCHEMAS'
139138
res = connection.execute(sql.text(query))
140139
return [row.Schema for row in res]
141140

142141
def get_table_names(self, connection: Connection, schema: str = None, **kw) -> List[str]:
143-
query = "SHOW TABLES"
142+
query = 'SHOW TABLES'
144143
if schema:
145-
query = f"{query} FROM {self.identifier_preparer.quote_identifier(schema)}"
144+
query = f'{query} FROM {self.identifier_preparer.quote_identifier(schema)}'
146145
res = connection.execute(sql.text(query))
147146
return [row.Table for row in res]
148147

@@ -153,12 +152,12 @@ def get_temp_table_names(self, connection: Connection, schema: str = None, **kw)
153152
def get_view_names(self, connection: Connection, schema: str = None, **kw) -> List[str]:
154153
schema = schema or self._get_default_schema_name(connection)
155154
if schema is None:
156-
raise exc.NoSuchTableError("schema is required")
157-
query = dedent("""
155+
raise exc.NoSuchTableError('schema is required')
156+
query = dedent('''
158157
SELECT "table_name"
159158
FROM "information_schema"."views"
160159
WHERE "table_schema" = :schema
161-
""").strip()
160+
''').strip()
162161
res = connection.execute(sql.text(query), schema=schema)
163162
return [row.table_name for row in res]
164163

@@ -168,7 +167,7 @@ def get_temp_view_names(self, connection: Connection, schema: str = None, **kw)
168167

169168
def get_view_definition(self, connection: Connection, view_name: str, schema: str = None, **kw) -> str:
170169
full_view = self._get_full_table(view_name, schema)
171-
query = f"SHOW CREATE VIEW {full_view}"
170+
query = f'SHOW CREATE VIEW {full_view}'
172171
try:
173172
res = connection.execute(sql.text(query))
174173
return res.first()[0]
@@ -184,11 +183,11 @@ def get_view_definition(self, connection: Connection, view_name: str, schema: st
184183
def get_indexes(self, connection: Connection,
185184
table_name: str, schema: str = None, **kw) -> List[Dict[str, Any]]:
186185
if not self.has_table(connection, table_name, schema):
187-
raise exc.NoSuchTableError(f"schema={schema}, table={table_name}")
186+
raise exc.NoSuchTableError(f'schema={schema}, table={table_name}')
188187

189-
partitioned_columns = self._get_columns(connection, f"{table_name}$partitions", schema, **kw)
188+
partitioned_columns = self._get_columns(connection, f'{table_name}$partitions', schema, **kw)
190189
partition_index = dict(
191-
name="partition",
190+
name='partition',
192191
column_names=[col['name'] for col in partitioned_columns],
193192
unique=False
194193
)
@@ -224,9 +223,9 @@ def has_schema(self, connection: Connection, schema: str) -> bool:
224223

225224
def has_table(self, connection: Connection,
226225
table_name: str, schema: str = None) -> bool:
227-
query = "SHOW TABLES"
226+
query = 'SHOW TABLES'
228227
if schema:
229-
query = f"{query} FROM {self.identifier_preparer.quote_identifier(schema)}"
228+
query = f'{query} FROM {self.identifier_preparer.quote_identifier(schema)}'
230229
query = f"{query} LIKE '{table_name}'"
231230
try:
232231
res = connection.execute(sql.text(query))
@@ -247,11 +246,11 @@ def has_sequence(self, connection: Connection,
247246
return False
248247

249248
def _get_server_version_info(self, connection: Connection) -> Tuple[int, ...]:
250-
query = dedent("""
249+
query = dedent('''
251250
SELECT *
252251
FROM system.runtime.nodes
253252
WHERE coordinator = true AND state = 'active'
254-
""").strip()
253+
''').strip()
255254
res = connection.execute(sql.text(query)).first()
256255
version = int(res.node_version)
257256
return tuple([version])
@@ -285,11 +284,11 @@ def set_isolation_level(self, dbapi_conn: trino_dbapi.Connection, level) -> None
285284
dbapi_conn._isolation_level = getattr(trino_dbapi.IsolationLevel, level)
286285

287286
def get_isolation_level(self, dbapi_conn: trino_dbapi.Connection) -> str:
288-
level_names = ["AUTOCOMMIT",
289-
"READ_UNCOMMITTED",
290-
"READ_COMMITTED",
291-
"REPEATABLE_READ",
292-
"SERIALIZABLE"]
287+
level_names = ['AUTOCOMMIT',
288+
'READ_UNCOMMITTED',
289+
'READ_COMMITTED',
290+
'REPEATABLE_READ',
291+
'SERIALIZABLE']
293292
return level_names[dbapi_conn.isolation_level]
294293

295294
def _get_full_table(self, table_name: str, schema: str = None, quote: bool = True) -> str:

0 commit comments

Comments
 (0)