@@ -167,8 +167,9 @@ def get_relations(self, cursor, table_name):
167
167
rc.UNIQUE_CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
168
168
WHERE
169
169
tc.TABLE_SCHEMA=@schema_name AND tc.TABLE_NAME=@view_name
170
- """ , params = {"schema_name" : schema_name , "view_name" : table_name }
171
- )
170
+ """ ,
171
+ params = {"schema_name" : schema_name , "view_name" : table_name },
172
+ )
172
173
return {
173
174
column : (referred_column , referred_table )
174
175
for (column , referred_column , referred_table ) in results
@@ -199,8 +200,9 @@ def get_primary_key_column(self, cursor, table_name):
199
200
ccu ON tc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
200
201
WHERE
201
202
tc.TABLE_NAME=@table_name AND tc.CONSTRAINT_TYPE='PRIMARY KEY' AND tc.TABLE_SCHEMA=@schema_name
202
- """ , params = {"schema_name" : schema_name , "table_name" : table_name }
203
- )
203
+ """ ,
204
+ params = {"schema_name" : schema_name , "table_name" : table_name },
205
+ )
204
206
return results [0 ][0 ] if results else None
205
207
206
208
def get_constraints (self , cursor , table_name ):
@@ -220,13 +222,13 @@ def get_constraints(self, cursor, table_name):
220
222
221
223
# Firstly populate all available constraints and their columns.
222
224
constraint_columns = cursor .run_sql_in_snapshot (
223
- '''
225
+ """
224
226
SELECT
225
227
CONSTRAINT_NAME, COLUMN_NAME
226
228
FROM
227
229
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
228
- WHERE TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name''' ,
229
- params = {"table" : table_name , "schema_name" : schema_name }
230
+ WHERE TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name""" ,
231
+ params = {"table" : table_name , "schema_name" : schema_name },
230
232
)
231
233
for constraint , column_name in constraint_columns :
232
234
if constraint not in constraints :
@@ -245,14 +247,14 @@ def get_constraints(self, cursor, table_name):
245
247
246
248
# Add the various constraints by type.
247
249
constraint_types = cursor .run_sql_in_snapshot (
248
- '''
250
+ """
249
251
SELECT
250
252
CONSTRAINT_NAME, CONSTRAINT_TYPE
251
253
FROM
252
254
INFORMATION_SCHEMA.TABLE_CONSTRAINTS
253
255
WHERE
254
- TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name''' ,
255
- params = {"table" : quoted_table_name , "schema_name" : schema_name }
256
+ TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name""" ,
257
+ params = {"table" : quoted_table_name , "schema_name" : schema_name },
256
258
)
257
259
for constraint , constraint_type in constraint_types :
258
260
already_added = constraint in constraints
@@ -298,7 +300,8 @@ def get_constraints(self, cursor, table_name):
298
300
idx.TABLE_NAME=@table AND idx.TABLE_SCHEMA=@schema_name
299
301
ORDER BY
300
302
idx_col.ORDINAL_POSITION
301
- """ , params = {"table" : quoted_table_name , "schema_name" : schema_name }
303
+ """ ,
304
+ params = {"table" : quoted_table_name , "schema_name" : schema_name },
302
305
)
303
306
for (
304
307
index_name ,
@@ -356,7 +359,8 @@ def get_key_columns(self, cursor, table_name):
356
359
rc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
357
360
WHERE
358
361
tc.TABLE_NAME=@table AND tc.TABLE_SCHEMA=@schema_name
359
- """ , params = {"table" : table_name , "schema_name" : schema_name }
362
+ """ ,
363
+ params = {"table" : table_name , "schema_name" : schema_name },
360
364
)
361
365
key_columns .extend (cursor .fetchall ())
362
366
return key_columns
0 commit comments