@@ -167,10 +167,11 @@ 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 = [
170
+ """ ,
171
+ params = [
171
172
{"schema_name" : schema_name },
172
- {"view_name" : self .connection .ops .quote_name (table_name )}
173
- ]
173
+ {"view_name" : self .connection .ops .quote_name (table_name )},
174
+ ],
174
175
)
175
176
return {
176
177
column : (referred_column , referred_table )
@@ -202,10 +203,11 @@ def get_primary_key_column(self, cursor, table_name):
202
203
ccu ON tc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
203
204
WHERE
204
205
tc.TABLE_NAME=@table_name AND tc.CONSTRAINT_TYPE='PRIMARY KEY' AND tc.TABLE_SCHEMA=@schema_name
205
- """ , params = [
206
+ """ ,
207
+ params = [
206
208
{"schema_name" : schema_name },
207
- {"table_name" : self .connection .ops .quote_name (table_name )}
208
- ]
209
+ {"table_name" : self .connection .ops .quote_name (table_name )},
210
+ ],
209
211
)
210
212
return results [0 ][0 ] if results else None
211
213
@@ -227,16 +229,16 @@ def get_constraints(self, cursor, table_name):
227
229
228
230
# Firstly populate all available constraints and their columns.
229
231
constraint_columns = cursor .run_sql_in_snapshot (
230
- '''
232
+ """
231
233
SELECT
232
234
CONSTRAINT_NAME, COLUMN_NAME
233
235
FROM
234
236
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
235
- WHERE TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name''' ,
237
+ WHERE TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name""" ,
236
238
params = [
237
239
{"table" : quoted_table_name },
238
- {"schema_name" : schema_name }
239
- ]
240
+ {"schema_name" : schema_name },
241
+ ],
240
242
)
241
243
for constraint , column_name in constraint_columns :
242
244
if constraint not in constraints :
@@ -255,16 +257,17 @@ def get_constraints(self, cursor, table_name):
255
257
256
258
# Add the various constraints by type.
257
259
constraint_types = cursor .run_sql_in_snapshot (
258
- '''
260
+ """
259
261
SELECT
260
262
CONSTRAINT_NAME, CONSTRAINT_TYPE
261
263
FROM
262
264
INFORMATION_SCHEMA.TABLE_CONSTRAINTS
263
265
WHERE
264
- TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name''' , params = [
266
+ TABLE_NAME=@table AND TABLE_SCHEMA=@schema_name""" ,
267
+ params = [
265
268
{"table" : quoted_table_name },
266
- {"schema_name" : schema_name }
267
- ]
269
+ {"schema_name" : schema_name },
270
+ ],
268
271
)
269
272
for constraint , constraint_type in constraint_types :
270
273
already_added = constraint in constraints
@@ -310,10 +313,11 @@ def get_constraints(self, cursor, table_name):
310
313
idx.TABLE_NAME=@table AND idx.TABLE_SCHEMA=@schema_name
311
314
ORDER BY
312
315
idx_col.ORDINAL_POSITION
313
- """ , params = [
316
+ """ ,
317
+ params = [
314
318
{"table" : quoted_table_name },
315
- {"schema_name" : schema_name }
316
- ]
319
+ {"schema_name" : schema_name },
320
+ ],
317
321
)
318
322
for (
319
323
index_name ,
@@ -371,10 +375,11 @@ def get_key_columns(self, cursor, table_name):
371
375
rc.CONSTRAINT_NAME = ccu.CONSTRAINT_NAME
372
376
WHERE
373
377
tc.TABLE_NAME=@table AND tc.TABLE_SCHEMA=@schema_name
374
- """ , params = [
378
+ """ ,
379
+ params = [
375
380
{"table" : self .connection .ops .quote_name (table_name )},
376
- {"schema_name" : schema_name }
377
- ]
381
+ {"schema_name" : schema_name },
382
+ ],
378
383
)
379
384
key_columns .extend (cursor .fetchall ())
380
385
return key_columns
0 commit comments