@@ -6300,11 +6300,11 @@ def relationship_to_join_clause(self, r_obj: Relationship):
6300
6300
6301
6301
def min_pk (self , table : str , pk_column : str ) -> int :
6302
6302
rows = self .execute (f"SELECT MIN({ pk_column } ) as min_pk FROM { table } " )
6303
- return rows .iloc [0 ]["min_pk" ]
6303
+ return rows .iloc [0 ]["min_pk" ]. tolist ()
6304
6304
6305
6305
def max_pk (self , table : str , pk_column : str ) -> int :
6306
6306
rows = self .execute (f"SELECT MAX({ pk_column } ) as max_pk FROM { table } " )
6307
- return rows .iloc [0 ]["max_pk" ]
6307
+ return rows .iloc [0 ]["max_pk" ]. tolist ()
6308
6308
6309
6309
def generate_join_clause (self , dataset : DataSet ) -> str :
6310
6310
"""
@@ -7083,9 +7083,7 @@ def column_info(self, table):
7083
7083
def pk_column (self , table ):
7084
7084
query = "SHOW KEYS FROM {} WHERE Key_name = 'PRIMARY'" .format (table )
7085
7085
rows = self .execute (query , silent = True )
7086
- for _ , row in rows .iterrows ():
7087
- return row ["Column_name" ]
7088
- return None
7086
+ return rows .iloc [0 ]["Column_name" ]
7089
7087
7090
7088
def relationships (self ):
7091
7089
# Return a list of dicts {from_table,to_table,from_column,to_column,requery}
@@ -7341,9 +7339,7 @@ def pk_column(self, table):
7341
7339
f"tc.table_name = '{ table } ' "
7342
7340
)
7343
7341
rows = self .execute (query , silent = True )
7344
- for _ , row in rows .iterrows ():
7345
- return row ["column_name" ]
7346
- return None
7342
+ return rows .iloc [0 ]["column_name" ]
7347
7343
7348
7344
def relationships (self ):
7349
7345
# Return a list of dicts {from_table,to_table,from_column,to_column,requery}
@@ -7389,15 +7385,15 @@ def min_pk(self, table: str, pk_column: str) -> int:
7389
7385
rows = self .execute (
7390
7386
f"SELECT COALESCE(MIN({ pk_column } ), 0) AS min_pk FROM { table } ;" , silent = True
7391
7387
)
7392
- return rows .fetchone ()[ "min_pk" ]
7388
+ return rows .iloc [ 0 ][ "min_pk" ]. tolist ()
7393
7389
7394
7390
def max_pk (self , table : str , pk_column : str ) -> int :
7395
7391
table = self .quote_table (table )
7396
7392
pk_column = self .quote_column (pk_column )
7397
7393
rows = self .execute (
7398
7394
f"SELECT COALESCE(MAX({ pk_column } ), 0) AS max_pk FROM { table } ;" , silent = True
7399
7395
)
7400
- return rows .fetchone ()[ "max_pk" ]
7396
+ return rows .iloc [ 0 ][ "max_pk" ]. tolist ()
7401
7397
7402
7398
def next_pk (self , table : str , pk_column : str ) -> int :
7403
7399
# Working with case-sensitive tables is painful in Postgres. First, the
@@ -7410,9 +7406,7 @@ def next_pk(self, table: str, pk_column: str) -> int:
7410
7406
# wrap the quoted string in singe quotes. Phew!
7411
7407
q = f"SELECT nextval('{ seq } ') LIMIT 1;"
7412
7408
rows = self .execute (q , silent = True )
7413
- for _ , row in rows .iterrows ():
7414
- return row ["nextval" ]
7415
- return None
7409
+ return rows .iloc [0 ]["nextval" ].tolist ()
7416
7410
7417
7411
def insert_record (self , table : str , pk : int , pk_column : str , row : dict ):
7418
7412
# insert_record() for Postgres is a little different from the rest. Instead of
@@ -7546,7 +7540,7 @@ def get_tables(self):
7546
7540
"SELECT table_name FROM information_schema.tables WHERE table_catalog = ?"
7547
7541
)
7548
7542
rows = self .execute (query , [self .database ], silent = True )
7549
- return [ row [ "table_name" ] for row in rows ]
7543
+ return list ( rows [ "table_name" ])
7550
7544
7551
7545
def column_info (self , table ):
7552
7546
# Return a list of column names
@@ -7562,10 +7556,10 @@ def column_info(self, table):
7562
7556
WHERE TABLE_NAME = ?
7563
7557
"""
7564
7558
pk_rows = self .execute (pk_query , [table ], silent = True )
7565
- for pk_row in pk_rows :
7559
+ for _ , pk_row in pk_rows . iterrows () :
7566
7560
pk_columns .append (pk_row ["COLUMN_NAME" ])
7567
7561
7568
- for row in rows :
7562
+ for _ , row in rows . iterrows () :
7569
7563
name = row ["COLUMN_NAME" ]
7570
7564
domain = row ["DATA_TYPE" ].upper ()
7571
7565
notnull = row ["IS_NULLABLE" ] == "NO"
@@ -7602,7 +7596,7 @@ def relationships(self):
7602
7596
7603
7597
rows = self .execute (query , silent = True )
7604
7598
7605
- for row in rows :
7599
+ for _ , row in rows . iterrows () :
7606
7600
dic = {}
7607
7601
dic ["from_table" ] = row ["from_table" ]
7608
7602
dic ["to_table" ] = row ["to_table" ]
@@ -7626,8 +7620,8 @@ def pk_column(self, table):
7626
7620
7627
7621
rows = self .execute (query , silent = True )
7628
7622
7629
- if rows :
7630
- return rows [0 ]["COLUMN_NAME" ]
7623
+ if not rows . empty :
7624
+ return rows . iloc [0 ]["COLUMN_NAME" ]
7631
7625
return None
7632
7626
7633
7627
0 commit comments