Skip to content

Commit a465cd4

Browse files
committed
More Result.set conversions
Access has issue with save and duplicate
1 parent 204842b commit a465cd4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pysimplesql/pysimplesql.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,7 @@ def duplicate_record(
19661966
self.frm.popup.ok(
19671967
lang.duplicate_failed_title,
19681968
lang.duplicate_failed.format_map(
1969-
LangFormat(exception=result.exception)
1969+
LangFormat(exception=result.attrs["exception"])
19701970
),
19711971
)
19721972
else:
@@ -7530,7 +7530,7 @@ def execute(
75307530

75317531
lastrowid = cursor.rowcount if cursor.rowcount else None
75327532

7533-
return pd.DataFrame(
7533+
return Result.set(
75347534
[
75357535
dict(zip([column[0] for column in cursor.description], row))
75367536
for row in rows
@@ -7758,10 +7758,10 @@ def execute(
77587758
row[column_name] = value
77597759
rows.append(row)
77607760

7761-
return pd.DataFrame(rows, None, exception, column_info)
7761+
return Result.set(rows, None, exception, column_info)
77627762

77637763
affected_rows = stmt.getUpdateCount()
7764-
return pd.DataFrame([], affected_rows, exception, column_info)
7764+
return Result.set([], affected_rows, exception, column_info)
77657765

77667766
def column_info(self, table):
77677767
meta_data = self.con.getMetaData()
@@ -7852,7 +7852,9 @@ def relationships(self):
78527852

78537853
def max_pk(self, table: str, pk_column: str) -> int:
78547854
rows = self.execute(f"SELECT MAX({pk_column}) as max_pk FROM {table}")
7855-
return rows.fetchone()["MAX_PK"] # returned as upper case
7855+
7856+
for _, row in rows.iterrows():
7857+
return row["MAX_PK"] # returned as upper case
78567858

78577859
def _get_column_definitions(self, table_name):
78587860
# Creates a comma separated list of column names and types to be used in a
@@ -7898,11 +7900,11 @@ def duplicate_record(self, dataset: DataSet, children: bool) -> pd.DataFrame:
78987900
]
78997901
for q in query:
79007902
res = self.execute(q)
7901-
if res.exception:
7903+
if res.attrs["exception"]:
79027904
return res
79037905

79047906
# Now we save the new pk
7905-
pk = res.lastrowid
7907+
pk = res.attrs["lastrowid"]
79067908

79077909
# create list of which children we have duplicated
79087910
child_duplicated = []
@@ -7943,7 +7945,7 @@ def duplicate_record(self, dataset: DataSet, children: bool) -> pd.DataFrame:
79437945
]
79447946
for q in queries:
79457947
res = self.execute(q)
7946-
if res.exception:
7948+
if res.attrs["exception"]:
79477949
return res
79487950

79497951
child_duplicated.append(r.child_table)

0 commit comments

Comments
 (0)