refactor: 优化数据库导出速度

This commit is contained in:
wanli
2023-09-07 11:15:11 +08:00
parent ecd79a2e15
commit 4d2e110e1e
2 changed files with 3 additions and 11 deletions

View File

@@ -342,6 +342,7 @@ const DbEdit = defineAsyncComponent(() => import('./DbEdit.vue'));
const CreateTable = defineAsyncComponent(() => import('./CreateTable.vue'));
const perms = {
base: 'db',
saveDb: 'db:save',
delDb: 'db:del',
};
@@ -357,7 +358,7 @@ const columns = ref([
]);
// 该用户拥有的的操作列按钮权限
const actionBtns = hasPerms([perms.saveDb]);
const actionBtns = hasPerms([perms.base, perms.saveDb]);
const actionColumn = TableColumn.new('action', '操作').isSlot().setMinWidth(150).fixedRight().alignCenter();
const pageTableRef: any = ref(null);

View File

@@ -313,13 +313,7 @@ func selectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]any, e
}
func walkTableRecord(db *sql.DB, selectSql string, walk func(record map[string]any, columns []string)) error {
tx, err := db.Begin()
if err != nil {
return err
}
defer tx.Rollback()
rows, err := tx.Query(selectSql)
rows, err := db.Query(selectSql)
if err != nil {
return err
}
@@ -362,9 +356,6 @@ func walkTableRecord(db *sql.DB, selectSql string, walk func(record map[string]a
walk(rowData, colNames)
}
if err := tx.Commit(); err != nil {
return err
}
return nil
}