@rudsys/n8n-nodes-sqlite3 0.1.2 → 0.1.4
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.
|
@@ -10,7 +10,7 @@ class SqliteSsh {
|
|
|
10
10
|
name: 'sqliteSsh',
|
|
11
11
|
icon: 'fa:database',
|
|
12
12
|
group: ['transform'],
|
|
13
|
-
version:
|
|
13
|
+
version: 2,
|
|
14
14
|
description: 'Execute SQLite operations on a remote server via SSH',
|
|
15
15
|
defaults: {
|
|
16
16
|
name: 'SQLite SSH',
|
|
@@ -52,10 +52,113 @@ class SqliteSsh {
|
|
|
52
52
|
{ name: 'Select', value: 'select', description: 'Select data from a table' },
|
|
53
53
|
{ name: 'Update', value: 'update', description: 'Update data in a table' },
|
|
54
54
|
{ name: 'Delete', value: 'delete', description: 'Delete data from a table' },
|
|
55
|
+
{ name: 'Table Operations', value: 'manageTables', description: 'Create, rename, drop, or list tables' },
|
|
56
|
+
{ name: 'Column Operations', value: 'manageColumns', description: 'Add, rename, drop, or list columns' },
|
|
55
57
|
{ name: 'Vacuum', value: 'vacuum', description: 'Rebuild the database file' },
|
|
56
58
|
],
|
|
57
59
|
default: 'executeQuery',
|
|
58
60
|
},
|
|
61
|
+
// ------------------ Table Operations ------------------
|
|
62
|
+
{
|
|
63
|
+
displayName: 'Action',
|
|
64
|
+
name: 'tableAction',
|
|
65
|
+
type: 'options',
|
|
66
|
+
displayOptions: { show: { operation: ['manageTables'] } },
|
|
67
|
+
options: [
|
|
68
|
+
{ name: 'List Tables', value: 'list' },
|
|
69
|
+
{ name: 'Create Table', value: 'create' },
|
|
70
|
+
{ name: 'Rename Table', value: 'rename' },
|
|
71
|
+
{ name: 'Drop Table', value: 'drop' },
|
|
72
|
+
],
|
|
73
|
+
default: 'list',
|
|
74
|
+
description: 'Action to perform on tables',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'New Table Name',
|
|
78
|
+
name: 'newTableName',
|
|
79
|
+
type: 'string',
|
|
80
|
+
displayOptions: {
|
|
81
|
+
show: {
|
|
82
|
+
operation: ['manageTables'],
|
|
83
|
+
tableAction: ['rename'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
default: '',
|
|
87
|
+
placeholder: 'my_renamed_table',
|
|
88
|
+
required: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: 'Columns Definition',
|
|
92
|
+
name: 'tableColumnsDefinition',
|
|
93
|
+
type: 'string',
|
|
94
|
+
displayOptions: {
|
|
95
|
+
show: {
|
|
96
|
+
operation: ['manageTables'],
|
|
97
|
+
tableAction: ['create'],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
default: 'id INTEGER PRIMARY KEY, name TEXT NOT NULL',
|
|
101
|
+
placeholder: 'id INTEGER PRIMARY KEY, name TEXT',
|
|
102
|
+
description: 'Comma-separated column definitions',
|
|
103
|
+
typeOptions: { rows: 4 },
|
|
104
|
+
},
|
|
105
|
+
// ------------------ Column Operations ------------------
|
|
106
|
+
{
|
|
107
|
+
displayName: 'Action',
|
|
108
|
+
name: 'columnAction',
|
|
109
|
+
type: 'options',
|
|
110
|
+
displayOptions: { show: { operation: ['manageColumns'] } },
|
|
111
|
+
options: [
|
|
112
|
+
{ name: 'List Columns', value: 'list' },
|
|
113
|
+
{ name: 'Add Column', value: 'add' },
|
|
114
|
+
{ name: 'Rename Column', value: 'rename' },
|
|
115
|
+
{ name: 'Drop Column', value: 'drop' },
|
|
116
|
+
],
|
|
117
|
+
default: 'list',
|
|
118
|
+
description: 'Action to perform on the table columns',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
displayName: 'Column Name',
|
|
122
|
+
name: 'columnName',
|
|
123
|
+
type: 'string',
|
|
124
|
+
displayOptions: {
|
|
125
|
+
show: {
|
|
126
|
+
operation: ['manageColumns'],
|
|
127
|
+
columnAction: ['add', 'rename', 'drop'],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
default: '',
|
|
131
|
+
placeholder: 'my_new_column',
|
|
132
|
+
required: true,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
displayName: 'New Column Name',
|
|
136
|
+
name: 'newColumnName',
|
|
137
|
+
type: 'string',
|
|
138
|
+
displayOptions: {
|
|
139
|
+
show: {
|
|
140
|
+
operation: ['manageColumns'],
|
|
141
|
+
columnAction: ['rename'],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
default: '',
|
|
145
|
+
placeholder: 'my_renamed_column',
|
|
146
|
+
required: true,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
displayName: 'Column Definition',
|
|
150
|
+
name: 'columnDefinition',
|
|
151
|
+
type: 'string',
|
|
152
|
+
displayOptions: {
|
|
153
|
+
show: {
|
|
154
|
+
operation: ['manageColumns'],
|
|
155
|
+
columnAction: ['add'],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
default: 'TEXT',
|
|
159
|
+
placeholder: 'TEXT NOT NULL DEFAULT ""',
|
|
160
|
+
description: 'Type and constraints (e.g., INTEGER PRIMARY KEY, TEXT DEFAULT "active")',
|
|
161
|
+
},
|
|
59
162
|
// ------------------ Execute Query ------------------
|
|
60
163
|
{
|
|
61
164
|
displayName: 'Query',
|
|
@@ -160,7 +263,7 @@ class SqliteSsh {
|
|
|
160
263
|
name: 'value',
|
|
161
264
|
type: 'string',
|
|
162
265
|
default: '',
|
|
163
|
-
|
|
266
|
+
displayOptions: { hide: { operator: ['isNull', 'isNotNull'] } },
|
|
164
267
|
},
|
|
165
268
|
],
|
|
166
269
|
},
|
|
@@ -282,6 +385,50 @@ class SqliteSsh {
|
|
|
282
385
|
else if (operation === 'executeQuery') {
|
|
283
386
|
sql = this.getNodeParameter('query', i);
|
|
284
387
|
}
|
|
388
|
+
else if (operation === 'manageTables') {
|
|
389
|
+
const action = this.getNodeParameter('tableAction', i);
|
|
390
|
+
if (action === 'list') {
|
|
391
|
+
sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';";
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
// For create, rename, drop - table param is used
|
|
395
|
+
// For create: table param is the NEW table name
|
|
396
|
+
// For rename: table param is OLD name, newTableName is NEW name
|
|
397
|
+
// For drop: table param is table to drop
|
|
398
|
+
if (action === 'create') {
|
|
399
|
+
const columnsDef = this.getNodeParameter('tableColumnsDefinition', i);
|
|
400
|
+
sql = `CREATE TABLE ${table} (${columnsDef});`;
|
|
401
|
+
}
|
|
402
|
+
else if (action === 'rename') {
|
|
403
|
+
const newName = escapeIdentifier(this.getNodeParameter('newTableName', i));
|
|
404
|
+
sql = `ALTER TABLE ${table} RENAME TO ${newName};`;
|
|
405
|
+
}
|
|
406
|
+
else if (action === 'drop') {
|
|
407
|
+
sql = `DROP TABLE ${table};`;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
else if (operation === 'manageColumns') {
|
|
412
|
+
const action = this.getNodeParameter('columnAction', i);
|
|
413
|
+
if (action === 'list') {
|
|
414
|
+
// PRAGMA table_info returns list of columns
|
|
415
|
+
sql = `PRAGMA table_info(${table});`;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
const colName = escapeIdentifier(this.getNodeParameter('columnName', i));
|
|
419
|
+
if (action === 'add') {
|
|
420
|
+
const colDef = this.getNodeParameter('columnDefinition', i);
|
|
421
|
+
sql = `ALTER TABLE ${table} ADD COLUMN ${colName} ${colDef};`;
|
|
422
|
+
}
|
|
423
|
+
else if (action === 'rename') {
|
|
424
|
+
const newColName = escapeIdentifier(this.getNodeParameter('newColumnName', i));
|
|
425
|
+
sql = `ALTER TABLE ${table} RENAME COLUMN ${colName} TO ${newColName};`;
|
|
426
|
+
}
|
|
427
|
+
else if (action === 'drop') {
|
|
428
|
+
sql = `ALTER TABLE ${table} DROP COLUMN ${colName};`;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
285
432
|
else if (operation === 'vacuum') {
|
|
286
433
|
sql = 'VACUUM;';
|
|
287
434
|
}
|