mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 09:05:59 +00:00
sqlite bulk insert
This commit is contained in:
@@ -24,8 +24,10 @@ class Analyser extends DatabaseAnalyser {
|
||||
'tables',
|
||||
tables.rows.map((x) => x.name)
|
||||
)) {
|
||||
const info = await this.driver.query(this.pool, `pragma table_info('${tableName}')`);
|
||||
const tableObj = tableList.find((x) => x.pureName == tableName);
|
||||
if (!tableObj) continue;
|
||||
|
||||
const info = await this.driver.query(this.pool, `pragma table_info('${tableName}')`);
|
||||
tableObj.columns = info.rows.map((col) => ({
|
||||
columnName: col.name,
|
||||
dataType: col.type,
|
||||
|
||||
@@ -3,6 +3,7 @@ const stream = require('stream');
|
||||
const driverBase = require('../frontend/driver');
|
||||
const Analyser = require('./Analyser');
|
||||
const { identify } = require('sql-query-identifier');
|
||||
const { createBulkInsertStreamBase, makeUniqueColumnNames } = require('dbgate-tools');
|
||||
|
||||
let Database;
|
||||
|
||||
@@ -59,15 +60,23 @@ const driver = {
|
||||
async query(pool, sql) {
|
||||
const stmt = pool.prepare(sql);
|
||||
// stmt.raw();
|
||||
const columns = stmt.columns();
|
||||
const rows = stmt.all();
|
||||
return {
|
||||
rows,
|
||||
columns: columns.map((col) => ({
|
||||
columnName: col.name,
|
||||
dataType: col.type,
|
||||
})),
|
||||
};
|
||||
if (stmt.reader) {
|
||||
const columns = stmt.columns();
|
||||
const rows = stmt.all();
|
||||
return {
|
||||
rows,
|
||||
columns: columns.map((col) => ({
|
||||
columnName: col.name,
|
||||
dataType: col.type,
|
||||
})),
|
||||
};
|
||||
} else {
|
||||
stmt.run();
|
||||
return {
|
||||
rows: [],
|
||||
columns: [],
|
||||
};
|
||||
}
|
||||
},
|
||||
async stream(client, sql, options) {
|
||||
const sqlSplitted = identify(sql, { dialect: 'sqlite', strict: false });
|
||||
|
||||
Reference in New Issue
Block a user