@@ -1966,7 +1966,7 @@ def duplicate_record(
1966
1966
self .frm .popup .ok (
1967
1967
lang .duplicate_failed_title ,
1968
1968
lang .duplicate_failed .format_map (
1969
- LangFormat (exception = result .exception )
1969
+ LangFormat (exception = result .attrs [ " exception" ] )
1970
1970
),
1971
1971
)
1972
1972
else :
@@ -7758,10 +7758,10 @@ def execute(
7758
7758
row [column_name ] = value
7759
7759
rows .append (row )
7760
7760
7761
- return pd . DataFrame (rows , None , exception , column_info )
7761
+ return Result . set (rows , None , exception , column_info )
7762
7762
7763
7763
affected_rows = stmt .getUpdateCount ()
7764
- return pd . DataFrame ([], affected_rows , exception , column_info )
7764
+ return Result . set ([], affected_rows , exception , column_info )
7765
7765
7766
7766
def column_info (self , table ):
7767
7767
meta_data = self .con .getMetaData ()
@@ -7852,7 +7852,7 @@ def relationships(self):
7852
7852
7853
7853
def max_pk (self , table : str , pk_column : str ) -> int :
7854
7854
rows = self .execute (f"SELECT MAX({ pk_column } ) as max_pk FROM { table } " )
7855
- return rows .fetchone () ["MAX_PK" ] # returned as upper case
7855
+ return rows .iloc [ 0 ] ["MAX_PK" ] # returned as upper case
7856
7856
7857
7857
def _get_column_definitions (self , table_name ):
7858
7858
# Creates a comma separated list of column names and types to be used in a
@@ -7862,6 +7862,7 @@ def _get_column_definitions(self, table_name):
7862
7862
for c in columns :
7863
7863
cols += f"{ c ['name' ]} { c ['domain' ]} , "
7864
7864
cols = cols [:- 2 ]
7865
+ print ("\n cols\n " , cols )
7865
7866
return cols
7866
7867
7867
7868
def duplicate_record (self , dataset : DataSet , children : bool ) -> pd .DataFrame :
@@ -7882,23 +7883,23 @@ def duplicate_record(self, dataset: DataSet, children: bool) -> pd.DataFrame:
7882
7883
# Create tmp table, update pk column in temp and insert into table
7883
7884
f"WHERE { pk_column } ={ dataset .get_current (dataset .pk_column )} "
7884
7885
query = [
7885
- f"DROP TABLE IF EXISTS [ { tmp_table } ] ;" ,
7886
- f"CREATE TABLE [ { tmp_table } ] ({ self ._get_column_definitions (table )} );" ,
7886
+ f"DROP TABLE IF EXISTS { tmp_table } ;" ,
7887
+ f"CREATE TABLE { tmp_table } ({ self ._get_column_definitions (table )} );" ,
7887
7888
(
7888
- f"INSERT INTO [ { tmp_table } ] (SELECT * FROM [ { table } ] "
7889
+ f"INSERT INTO { tmp_table } (SELECT * FROM { table } "
7889
7890
f"WHERE { pk_column } ={ dataset .get_current (dataset .pk_column )} );"
7890
7891
),
7891
7892
(
7892
- f"UPDATE [ { tmp_table } ] SET { pk_column } = "
7893
+ f"UPDATE { tmp_table } SET { pk_column } = "
7893
7894
f"{ self .next_pk (dataset .table , dataset .pk_column )} ;"
7894
7895
),
7895
- f"UPDATE [ { tmp_table } ] SET { description_column } = { description } " ,
7896
- f"INSERT INTO [ { table } ] SELECT * FROM [ { tmp_table } ] ;" ,
7897
- f"DROP TABLE IF EXISTS [ { tmp_table } ] " ,
7896
+ f"UPDATE { tmp_table } ]SET { description_column } = { description } " ,
7897
+ f"INSERT INTO { table } SELECT * FROM { tmp_table } ;" ,
7898
+ f"DROP TABLE IF EXISTS { tmp_table } " ,
7898
7899
]
7899
7900
for q in query :
7900
7901
res = self .execute (q )
7901
- if res .exception :
7902
+ if res .attrs [ " exception" ] :
7902
7903
return res
7903
7904
7904
7905
# Now we save the new pk
@@ -7925,21 +7926,21 @@ def duplicate_record(self, dataset: DataSet, children: bool) -> pd.DataFrame:
7925
7926
# Update children's pk_columns to NULL and set correct parent
7926
7927
# PK value.
7927
7928
queries = [
7928
- f"DROP TABLE IF EXISTS [ { tmp_child } ] " ,
7929
+ f"DROP TABLE IF EXISTS { tmp_child } " ,
7929
7930
(
7930
- f"CREATE TABLE [ { tmp_table } ] "
7931
+ f"CREATE TABLE { tmp_table } "
7931
7932
f"({ self ._get_column_definitions (table )} );"
7932
7933
),
7933
7934
(
7934
- f"INSERT INTO [ { tmp_table } ] (SELECT * FROM [ { table } ] "
7935
+ f"INSERT INTO { tmp_table } (SELECT * FROM { table } "
7935
7936
f"WHERE { pk_column } ="
7936
7937
f"{ dataset .get_current (dataset .pk_column )} );"
7937
7938
),
7938
7939
# don't next_pk(), because child can be plural.
7939
- f"UPDATE [ { tmp_child } ] SET { pk_column } = NULL;" ,
7940
- f"UPDATE [ { tmp_child } ] SET { fk_column } = { pk } " ,
7941
- f"INSERT INTO [ { child } ] SELECT * FROM [ { tmp_child } ] ;" ,
7942
- f"DROP TABLE IF EXISTS [ { tmp_child } ] " ,
7940
+ f"UPDATE { tmp_child } SET { pk_column } = NULL;" ,
7941
+ f"UPDATE { tmp_child } SET { fk_column } = { pk } " ,
7942
+ f"INSERT INTO { child } SELECT * FROM { tmp_child } ;" ,
7943
+ f"DROP TABLE IF EXISTS { tmp_child } " ,
7943
7944
]
7944
7945
for q in queries :
7945
7946
res = self .execute (q )
0 commit comments