feat: add new duck db command

This commit is contained in:
Nybkox
2025-04-08 18:56:17 +02:00
parent ca18994092
commit b8d86518e7
5 changed files with 46 additions and 4 deletions

View File

@@ -435,6 +435,22 @@ module.exports = {
return res;
},
newDuckdbDatabase_meta: true,
async newDuckdbDatabase({ file }) {
const duckdbDir = path.join(filesdir(), 'duckdb');
if (!(await fs.exists(duckdbDir))) {
await fs.mkdir(duckdbDir);
}
const databaseFile = path.join(duckdbDir, `${file}.duckdb`);
const res = await this.save({
engine: 'duckdb@dbgate-plugin-duckdb',
databaseFile,
singleDatabase: true,
defaultDatabase: `${file}.duckdb`,
});
return res;
},
dbloginWeb_meta: {
raw: true,
method: 'get',

Binary file not shown.

View File

@@ -46,6 +46,7 @@ import { openImportExportTab } from '../utility/importExportTools';
import newTable from '../tableeditor/newTable';
import { isProApp } from '../utility/proTools';
import { openWebLink } from '../utility/simpleTools';
import { _t } from '../translations';
// function themeCommand(theme: ThemeDefinition) {
// return {
@@ -389,12 +390,12 @@ registerCommand({
category: 'New',
icon: 'img sqlite-database',
name: 'SQLite database',
menuName: 'New SQLite database',
menuName: _t('command.new.sqliteDatabase', { defaultMessage: 'New SQLite database' }),
onClick: () => {
showModal(InputTextModal, {
value: 'newdb',
label: 'New database name',
header: 'Create SQLite database',
label: _t('command.new.sqliteDatabase', { defaultMessage: 'New SQLite database' }),
header: _t('command.new.sqliteDatabase.header', { defaultMessage: 'Create SQLite database' }),
onConfirm: async file => {
const resp = await apiCall('connections/new-sqlite-database', { file });
const connection = resp;
@@ -404,6 +405,26 @@ registerCommand({
},
});
registerCommand({
id: 'new.duckdbDatabase',
category: 'New',
icon: 'img sqlite-database',
name: 'DuckDB database',
menuName: _t('command.new.duckdbDatabase', { defaultMessage: 'New DuckDB database' }),
onClick: () => {
showModal(InputTextModal, {
value: 'newdb',
label: _t('command.new.duckdbDatabase', { defaultMessage: 'New DuckDB database' }),
header: _t('command.new.duckdbDatabase.header', { defaultMessage: 'Create DuckDB database' }),
onConfirm: async file => {
const resp = await apiCall('connections/new-duckdb-database', { file });
const connection = resp;
switchCurrentDatabase({ connection, name: `${file}.duckdb` });
},
});
},
});
registerCommand({
id: 'tabs.changelog',
category: 'Tabs',