@deepagents/text2sql 7.1.2 → 7.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1701,6 +1701,7 @@ function rowCount(config = {}) {
1701
1701
  }
1702
1702
 
1703
1703
  // packages/text2sql/src/lib/adapters/spreadsheet/spreadsheet.ts
1704
+ import { transaction } from "@zukhruf/sqlite-transaction";
1704
1705
  import { DatabaseSync } from "node:sqlite";
1705
1706
 
1706
1707
  // packages/text2sql/src/lib/adapters/spreadsheet/parser.ts
@@ -1877,23 +1878,19 @@ function loadData(db, sheet) {
1877
1878
  const placeholders = sheet.columns.map(() => "?").join(", ");
1878
1879
  const insertSQL = `INSERT INTO "${escapeIdentifier(sheet.name)}" (${columns}) VALUES (${placeholders})`;
1879
1880
  const stmt = db.prepare(insertSQL);
1880
- db.exec("BEGIN TRANSACTION");
1881
- try {
1882
- for (const row of sheet.rows) {
1883
- const values = sheet.columns.map((col) => {
1884
- const rawValue = row[col.originalKey];
1885
- return convertValue(rawValue, col.type);
1886
- });
1887
- stmt.run(...values);
1888
- }
1889
- db.exec("COMMIT");
1890
- } catch (error) {
1891
- try {
1892
- db.exec("ROLLBACK");
1893
- } catch {
1894
- }
1895
- throw error;
1896
- }
1881
+ transaction(
1882
+ db,
1883
+ () => {
1884
+ for (const row of sheet.rows) {
1885
+ const values = sheet.columns.map((col) => {
1886
+ const rawValue = row[col.originalKey];
1887
+ return convertValue(rawValue, col.type);
1888
+ });
1889
+ stmt.run(...values);
1890
+ }
1891
+ },
1892
+ { mode: "deferred" }
1893
+ );
1897
1894
  }
1898
1895
  function convertValue(value, type) {
1899
1896
  if (value == null || value === "") {