1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

Compare commits

...

21 Commits

Author SHA1 Message Date
53a71d55c5 chore(release): 0.7.10 2023-05-28 13:32:38 +02:00
03638c0553 feat: copy rows as PHP array 2023-05-28 13:31:44 +02:00
8968179c11 feat: export table content or query results as PHP array, closes #575 2023-05-28 13:20:28 +02:00
2c0b4ffe1f fix: disable shorctut to show Ace editor settings, fixes #585 2023-05-26 18:17:23 +02:00
f454b4bb1c feat: DDL query in table settings for MySQL and PostgreSQL, closes #581 2023-05-25 18:51:56 +02:00
56698725cb Merge pull request #583 from m1khal3v/patch-2
Update ru-RU.ts
2023-05-21 00:40:16 +02:00
Anton Mikhalev
1896013267 Update ru-RU.ts 2023-05-19 14:14:35 +03:00
17eeb6d38e feat: keepalive on mysql/postgre connections, should fix #577 2023-05-14 18:48:21 +02:00
5e83b4466d Merge pull request #574 from antares-sql/all-contributors/add-m1khal3v
docs: add m1khal3v as a contributor for translation
2023-05-05 09:13:09 +02:00
allcontributors[bot]
45d1934f96 docs: update .all-contributorsrc [skip ci] 2023-05-05 07:12:57 +00:00
allcontributors[bot]
7821e25bdb docs: update README.md [skip ci] 2023-05-05 07:12:56 +00:00
ae8d558989 Merge pull request #572 from m1khal3v/patch-1
Update ru-RU.ts
2023-05-05 09:12:12 +02:00
Anton Mikhalev
b348c83501 Update ru-RU.ts 2023-05-04 16:11:10 +03:00
Anton Mikhalev
f58a12ebd5 Update ru-RU.ts 2023-05-04 16:01:17 +03:00
Anton Mikhalev
b806deeed0 Update ru-RU.ts 2023-05-04 14:36:47 +03:00
Anton Mikhalev
4e1be838bd Update ru-RU.ts 2023-05-04 14:19:38 +03:00
Anton Mikhalev
bb7ec76ced Update ru-RU.ts 2023-05-04 14:05:12 +03:00
Anton Mikhalev
e2b843cd18 Update ru-RU.ts 2023-05-04 14:01:52 +03:00
8c9713e805 ci: action to create linux arm64 artifacts 2023-05-02 08:57:14 +02:00
786de6a7ba ci: disable arm64 linux target 2023-05-01 13:41:01 +02:00
1bf54a69fd ci: disable arm deb target 2023-05-01 13:11:41 +02:00
31 changed files with 552 additions and 95 deletions

View File

@@ -211,6 +211,15 @@
"contributions": [
"translation"
]
},
{
"login": "m1khal3v",
"name": "Anton Mikhalev",
"avatar_url": "https://avatars.githubusercontent.com/u/41085561?v=4",
"profile": "https://github.com/m1khal3v",
"contributions": [
"translation"
]
}
],
"contributorsPerLine": 7,

View File

@@ -0,0 +1,32 @@
name: Create artifact [LINUX ARM64]
on:
workflow_dispatch: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm i
- name: "Build"
run: npm run build -- --arm64 --linux deb AppImage
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: linux-build
retention-days: 3
path: |
build
!build/*-unpacked
!build/.icon-ico

View File

@@ -2,6 +2,21 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.7.10](https://github.com/antares-sql/antares/compare/v0.7.9...v0.7.10) (2023-05-28)
### Features
* copy rows as PHP array ([03638c0](https://github.com/antares-sql/antares/commit/03638c05534e9ce2e594ce5945485587ed99e609))
* DDL query in table settings for MySQL and PostgreSQL, closes [#581](https://github.com/antares-sql/antares/issues/581) ([f454b4b](https://github.com/antares-sql/antares/commit/f454b4bb1ca79eec285b3b4039a2ef66802ff82a))
* export table content or query results as PHP array, closes [#575](https://github.com/antares-sql/antares/issues/575) ([8968179](https://github.com/antares-sql/antares/commit/8968179c11f4fe3e624873aac4685a5a33521024))
* keepalive on mysql/postgre connections, should fix [#577](https://github.com/antares-sql/antares/issues/577) ([17eeb6d](https://github.com/antares-sql/antares/commit/17eeb6d38e45b553e35e004b748569971743ca18))
### Bug Fixes
* disable shorctut to show Ace editor settings, fixes [#585](https://github.com/antares-sql/antares/issues/585) ([2c0b4ff](https://github.com/antares-sql/antares/commit/2c0b4ffe1f2e418f5e9120a40787788d8e7fd27e))
### [0.7.9](https://github.com/antares-sql/antares/compare/v0.7.8...v0.7.9) (2023-05-01)

View File

@@ -146,6 +146,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/555cider"><img src="https://avatars.githubusercontent.com/u/73565447?v=4?s=100" width="100px;" alt="555cider"/><br /><sub><b>555cider</b></sub></a><br /><a href="#translation-555cider" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/m1khal3v"><img src="https://avatars.githubusercontent.com/u/41085561?v=4?s=100" width="100px;" alt="Anton Mikhalev"/><br /><sub><b>Anton Mikhalev</b></sub></a><br /><a href="#translation-m1khal3v" title="Translation">🌍</a></td>
</tr>
</tbody>
</table>

15
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "antares",
"version": "0.7.9",
"version": "0.7.10",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "antares",
"version": "0.7.9",
"version": "0.7.10",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -23,6 +23,7 @@
"electron-window-state": "~5.0.3",
"encoding": "~0.1.13",
"floating-vue": "~2.0.0-beta.20",
"json2php": "~0.0.7",
"leaflet": "~1.7.1",
"marked": "~4.0.19",
"moment": "~2.29.4",
@@ -8642,6 +8643,11 @@
"devOptional": true,
"license": "ISC"
},
"node_modules/json2php": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/json2php/-/json2php-0.0.7.tgz",
"integrity": "sha512-dnSoUiLAoVaMXxFsVi4CrPVYMKOuDBXTghXSmMINX44RZ8WM9cXlY7UqrQnlAcODCVO7FV3+8t/5nDKAjimLfg=="
},
"node_modules/json5": {
"version": "2.2.1",
"dev": true,
@@ -19965,6 +19971,11 @@
"version": "5.0.1",
"devOptional": true
},
"json2php": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/json2php/-/json2php-0.0.7.tgz",
"integrity": "sha512-dnSoUiLAoVaMXxFsVi4CrPVYMKOuDBXTghXSmMINX44RZ8WM9cXlY7UqrQnlAcODCVO7FV3+8t/5nDKAjimLfg=="
},
"json5": {
"version": "2.2.1",
"dev": true

View File

@@ -1,7 +1,7 @@
{
"name": "antares",
"productName": "Antares",
"version": "0.7.9",
"version": "0.7.10",
"description": "A modern, fast and productivity driven SQL client with a focus in UX.",
"license": "MIT",
"repository": "https://github.com/antares-sql/antares.git",
@@ -66,16 +66,14 @@
"target": "deb",
"arch": [
"x64",
"armv7l",
"arm64"
"armv7l"
]
},
{
"target": "AppImage",
"arch": [
"x64",
"armv7l",
"arm64"
"armv7l"
]
}
],
@@ -132,6 +130,7 @@
"electron-window-state": "~5.0.3",
"encoding": "~0.1.13",
"floating-vue": "~2.0.0-beta.20",
"json2php": "~0.0.7",
"leaflet": "~1.7.1",
"marked": "~4.0.19",
"moment": "~2.29.4",

View File

@@ -31,11 +31,12 @@ export const defaults: Customizations = {
routines: false,
functions: false,
schedulers: false,
// Settings
// Misc
elementsWrapper: '',
stringsWrapper: '"',
tableAdd: false,
tableTruncateDisableFKCheck: false,
tableDdl: false,
viewAdd: false,
triggerAdd: false,
triggerFunctionAdd: false,

View File

@@ -44,6 +44,7 @@ export const customizations: Customizations = {
tableAdd: true,
tableTruncateDisableFKCheck: true,
tableDuplicate: true,
tableDdl: true,
viewAdd: true,
triggerAdd: true,
routineAdd: true,

View File

@@ -35,11 +35,12 @@ export const customizations: Customizations = {
triggerFunctions: true,
routines: true,
functions: true,
// Settings
// Misc
elementsWrapper: '"',
stringsWrapper: '\'',
tableAdd: true,
tableDuplicate: true,
tableDdl: true,
viewAdd: true,
triggerAdd: true,
triggerFunctionAdd: true,

View File

@@ -30,7 +30,7 @@ export interface Customizations {
routines?: boolean;
functions?: boolean;
schedulers?: boolean;
// Settings
// Misc
elementsWrapper: string;
stringsWrapper: string;
tableAdd?: boolean;
@@ -39,6 +39,7 @@ export interface Customizations {
tableArray?: boolean;
tableRealCount?: boolean;
tableTruncateDisableFKCheck?: boolean;
tableDdl?: boolean;
viewAdd?: boolean;
viewSettings?: boolean;
triggerAdd?: boolean;

View File

@@ -75,6 +75,17 @@ export default (connections: {[key: string]: antares.Client}) => {
}
});
ipcMain.handle('get-table-ddl', async (event, params) => {
try {
const result = await connections[params.uid].getTableDll(params);
return { status: 'success', response: result };
}
catch (err) {
return { status: 'error', response: err.toString() };
}
});
ipcMain.handle('get-key-usage', async (event, params) => {
try {
const result = await connections[params.uid].getKeyUsage(params);

View File

@@ -174,6 +174,10 @@ export abstract class AntaresCore {
throw new Error('Method "dropSchema" not implemented');
}
getTableDll (...args: any) {
throw new Error('Method "getTableDll" not implemented');
}
getDatabaseCollation (...args: any) {
throw new Error('Method "getDatabaseCollation" not implemented');
}

View File

@@ -9,6 +9,8 @@ export class MySQLClient extends AntaresCore {
private _schema?: string;
private _runningConnections: Map<string, number>;
private _connectionsToCommit: Map<string, mysql.Connection | mysql.PoolConnection>;
private _keepaliveTimer: NodeJS.Timer;
private _keepaliveMs: number;
_connection?: mysql.Connection | mysql.Pool;
_params: mysql.ConnectionOptions & {schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean};
@@ -52,6 +54,7 @@ export class MySQLClient extends AntaresCore {
this._schema = null;
this._runningConnections = new Map();
this._connectionsToCommit = new Map();
this._keepaliveMs = 10*60*1000;
}
private _getType (field: mysql.FieldPacket & { columnType?: number; columnLength?: number }) {
@@ -182,6 +185,8 @@ export class MySQLClient extends AntaresCore {
destroy () {
this._connection.end();
clearInterval(this._keepaliveTimer);
this._keepaliveTimer = undefined;
if (this._ssh) this._ssh.close();
}
@@ -243,9 +248,19 @@ export class MySQLClient extends AntaresCore {
conn.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
});
this._keepaliveTimer = setInterval(async () => {
await this.keepAlive();
}, this._keepaliveMs);
return connection;
}
private async keepAlive () {
const connection = await (this._connection as mysql.Pool).getConnection();
await connection.ping();
connection.release();
}
use (schema: string) {
this._schema = schema;
return this.raw(`USE \`${schema}\``);
@@ -686,6 +701,17 @@ export class MySQLClient extends AntaresCore {
});
}
async getTableDll ({ schema, table }: { schema: string; table: string }) {
const { rows } = await this.raw<antares.QueryResult<{
'Create Table'?: string;
Table: string;
}>>(`SHOW CREATE TABLE \`${schema}\`.\`${table}\``);
if (rows.length)
return rows[0]['Create Table'];
else return '';
}
async getKeyUsage ({ schema, table }: { schema: string; table: string }) {
interface KeyResult {
TABLE_SCHEMA: string;

View File

@@ -84,6 +84,8 @@ export class PostgreSQLClient extends AntaresCore {
private _schema?: string;
private _runningConnections: Map<string, number>;
private _connectionsToCommit: Map<string, pg.Client | pg.PoolClient>;
private _keepaliveTimer: NodeJS.Timer;
private _keepaliveMs: number;
protected _connection?: pg.Client | pg.Pool;
private types: {[key: string]: string} = {};
private _arrayTypes: {[key: string]: string} = {
@@ -104,6 +106,7 @@ export class PostgreSQLClient extends AntaresCore {
this._schema = null;
this._runningConnections = new Map();
this._connectionsToCommit = new Map();
this._keepaliveMs = 10*60*1000;
for (const key in pg.types.builtins) {
const builtinKey = key as builtinsTypes;
@@ -222,14 +225,26 @@ export class PostgreSQLClient extends AntaresCore {
});
}
this._keepaliveTimer = setInterval(async () => {
await this.keepAlive();
}, this._keepaliveMs);
return connection;
}
destroy () {
this._connection.end();
clearInterval(this._keepaliveTimer);
this._keepaliveTimer = undefined;
if (this._ssh) this._ssh.close();
}
private async keepAlive () {
const connection = await this._connection.connect() as pg.PoolClient;
await connection.query('SELECT 1+1');
connection.release();
}
use (schema: string, connection?: pg.Client | pg.PoolClient) {
this._schema = schema;
@@ -567,6 +582,142 @@ export class PostgreSQLClient extends AntaresCore {
}, {} as {table: string; schema: string}[]);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getTableDll ({ schema, table }: { schema: string; table: string }) {
// const { rows } = await this.raw<antares.QueryResult<{'ddl'?: string}>>(`
// SELECT
// 'CREATE TABLE ' || relname || E'\n(\n' ||
// array_to_string(
// array_agg(' ' || column_name || ' ' || type || ' '|| not_null)
// , E',\n'
// ) || E'\n);\n' AS ddl
// FROM (
// SELECT
// a.attname AS column_name
// , pg_catalog.format_type(a.atttypid, a.atttypmod) AS type
// , CASE WHEN a.attnotnull THEN 'NOT NULL' ELSE 'NULL' END AS not_null
// , c.relname
// FROM pg_attribute a, pg_class c, pg_type t
// WHERE a.attnum > 0
// AND a.attrelid = c.oid
// AND a.atttypid = t.oid
// AND c.relname = '${table}'
// ORDER BY a.attnum
// ) AS tabledefinition
// GROUP BY relname
// `);
// if (rows.length)
// return rows[0].ddl;
// else return '';
/* eslint-disable camelcase */
interface SequenceRecord {
sequence_catalog: string;
sequence_schema: string;
sequence_name: string;
data_type: string;
numeric_precision: number;
numeric_precision_radix: number;
numeric_scale: number;
start_value: string;
minimum_value: string;
maximum_value: string;
increment: string;
cycle_option: string;
}
/* eslint-enable camelcase */
let createSql = '';
const sequences = [];
const columnsSql = [];
const arrayTypes: {[key: string]: string} = {
_int2: 'smallint',
_int4: 'integer',
_int8: 'bigint',
_float4: 'real',
_float8: 'double precision',
_char: '"char"',
_varchar: 'character varying'
};
// Table columns
const { rows } = await this.raw(`
SELECT *
FROM "information_schema"."columns"
WHERE "table_schema" = '${schema}'
AND "table_name" = '${table}'
ORDER BY "ordinal_position" ASC
`, { schema: 'information_schema' });
if (!rows.length) return '';
for (const column of rows) {
let fieldType = column.data_type;
if (fieldType === 'USER-DEFINED') fieldType = `"${schema}".${column.udt_name}`;
else if (fieldType === 'ARRAY') {
if (Object.keys(arrayTypes).includes(fieldType))
fieldType = arrayTypes[column.udt_name] + '[]';
else
fieldType = column.udt_name.replaceAll('_', '') + '[]';
}
const columnArr = [
`"${column.column_name}"`,
`${fieldType}${column.character_maximum_length ? `(${column.character_maximum_length})` : ''}`
];
if (column.column_default) {
columnArr.push(`DEFAULT ${column.column_default}`);
if (column.column_default.includes('nextval')) {
const sequenceName = column.column_default.split('\'')[1];
sequences.push(sequenceName);
}
}
if (column.is_nullable === 'NO') columnArr.push('NOT NULL');
columnsSql.push(columnArr.join(' '));
}
// Table sequences
for (let sequence of sequences) {
if (sequence.includes('.')) sequence = sequence.split('.')[1];
const { rows } = await this.select('*')
.schema('information_schema')
.from('sequences')
.where({ sequence_schema: `= '${schema}'`, sequence_name: `= '${sequence}'` })
.run<SequenceRecord>();
if (rows.length) {
createSql += `CREATE SEQUENCE "${schema}"."${sequence}"
START WITH ${rows[0].start_value}
INCREMENT BY ${rows[0].increment}
MINVALUE ${rows[0].minimum_value}
MAXVALUE ${rows[0].maximum_value}
CACHE 1;\n`;
}
}
// Table create
createSql += `\nCREATE TABLE "${schema}"."${table}"(
${columnsSql.join(',\n ')}
);\n`;
// Table indexes
createSql += '\n';
const { rows: indexes } = await this.select('*')
.schema('pg_catalog')
.from('pg_indexes')
.where({ schemaname: `= '${schema}'`, tablename: `= '${table}'` })
.run<{indexdef: string}>();
for (const index of indexes)
createSql += `${index.indexdef};\n`;
return createSql;
}
async getKeyUsage ({ schema, table }: { schema: string; table: string }) {
/* eslint-disable camelcase */
interface KeyResult {

View File

@@ -7,7 +7,7 @@ import MysqlExporter from '../libs/exporters/sql/MysqlExporter';
import PostgreSQLExporter from '../libs/exporters/sql/PostgreSQLExporter';
let exporter: antares.Exporter;
process.on('message', async ({ type, client, tables, options }) => {
process.on('message', async ({ type, client, tables, options }: any) => {
if (type === 'init') {
const connection = await ClientsFactory.getClient({
client: client.name,

View File

@@ -44,6 +44,11 @@ watch(() => props.mode, () => {
editor.session.setMode(`ace/mode/${props.mode}`);
});
watch(() => props.modelValue, () => {
if (editor)
editor.session.setValue(props.modelValue);
});
watch(editorTheme, () => {
if (editor)
editor.setTheme(`ace/theme/${editorTheme.value}`);
@@ -113,6 +118,8 @@ onMounted(() => {
}, 20);
}
editor.commands.removeCommand('showSettingsMenu');
setTimeout(() => {
editor.resize();
}, 20);

View File

@@ -373,6 +373,8 @@ onMounted(() => {
e.stop();
});
editor.value.commands.removeCommand('showSettingsMenu');
if (props.autoFocus) {
setTimeout(() => {
editor.value.focus();

View File

@@ -416,7 +416,7 @@ const clients = [
{ name: 'MariaDB', slug: 'maria' },
{ name: 'PostgreSQL', slug: 'pg' },
{ name: 'SQLite', slug: 'sqlite' },
{ name: 'Firebird SQL (experimental)', slug: 'firebird' }
{ name: 'Firebird SQL', slug: 'firebird' }
];
const connection = ref({

View File

@@ -429,7 +429,7 @@ const clients = [
{ name: 'MariaDB', slug: 'maria' },
{ name: 'PostgreSQL', slug: 'pg' },
{ name: 'SQLite', slug: 'sqlite' },
{ name: 'Firebird SQL (experimental)', slug: 'firebird' }
{ name: 'Firebird SQL', slug: 'firebird' }
];
const firstInput: Ref<HTMLInputElement> = ref(null);

View File

@@ -43,13 +43,25 @@
<span>{{ t('word.indexes') }}</span>
</button>
<button
class="btn btn-dark btn-sm"
class="btn btn-dark btn-sm mr-0"
:disabled="isSaving"
@click="showForeignModal"
>
<i class="mdi mdi-24px mdi-key-link mr-1" />
<span>{{ t('word.foreignKeys') }}</span>
</button>
<div class="divider-vert py-3" />
<button
v-if="workspace.customizations.tableDdl"
class="btn btn-dark btn-sm"
:disabled="isSaving"
@click="showDdlModal"
>
<i class="mdi mdi-24px mdi-code-tags mr-1" />
<span>{{ t('word.ddl') }}</span>
</button>
</div>
<div class="workspace-query-info">
<div class="d-flex" :title="t('word.schema')">
@@ -169,6 +181,13 @@
@hide="hideForeignModal"
@foreigns-update="foreignsUpdate"
/>
<WorkspaceTabPropsTableDdlModal
v-if="isDdlModal"
:table="table"
:schema="schema"
:workspace="workspace"
@hide="hideDdlModal"
/>
</div>
</template>
@@ -186,6 +205,7 @@ import BaseSelect from '@/components/BaseSelect.vue';
import WorkspaceTabPropsTableFields from '@/components/WorkspaceTabPropsTableFields.vue';
import WorkspaceTabPropsTableIndexesModal from '@/components/WorkspaceTabPropsTableIndexesModal.vue';
import WorkspaceTabPropsTableForeignModal from '@/components/WorkspaceTabPropsTableForeignModal.vue';
import WorkspaceTabPropsTableDdlModal from '@/components/WorkspaceTabPropsTableDdlModal.vue';
import { ipcRenderer } from 'electron';
import { useSettingsStore } from '@/stores/settings';
@@ -221,6 +241,7 @@ const isLoading = ref(false);
const isSaving = ref(false);
const isIndexesModal = ref(false);
const isForeignModal = ref(false);
const isDdlModal = ref(false);
const originalFields: Ref<TableField[]> = ref([]);
const localFields: Ref<TableField[]> = ref([]);
const originalKeyUsage: Ref<TableForeign[]> = ref([]);
@@ -649,6 +670,14 @@ const hideForeignModal = () => {
isForeignModal.value = false;
};
const showDdlModal = () => {
isDdlModal.value = true;
};
const hideDdlModal = () => {
isDdlModal.value = false;
};
const foreignsUpdate = (foreigns: TableForeign[]) => {
localKeyUsage.value = foreigns;
};

View File

@@ -0,0 +1,70 @@
<template>
<ConfirmModal
:confirm-text="t('word.confirm')"
size="large"
class="options-modal"
:cancel-text="t('word.close')"
:hide-footer="true"
@hide="$emit('hide')"
>
<template #header>
<div class="d-flex">
<i class="mdi mdi-24px mdi-code-tags mr-1" />
<span class="cut-text">{{ t('word.ddl') }} "{{ table }}"</span>
</div>
</template>
<template #body>
<div class="pb-4">
<BaseTextEditor
ref="queryEditor"
v-model="createDdl"
editor-class="textarea-editor"
:read-only="true"
mode="sql"
/>
</div>
</template>
</ConfirmModal>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useNotificationsStore } from '@/stores/notifications';
import { useI18n } from 'vue-i18n';
import Tables from '@/ipc-api/Tables';
import ConfirmModal from '@/components/BaseConfirmModal.vue';
import BaseTextEditor from '@/components/BaseTextEditor.vue';
const { t } = useI18n();
const props = defineProps({
table: String,
schema: String,
workspace: Object
});
const createDdl = ref('');
defineEmits(['hide']);
const { addNotification } = useNotificationsStore();
onMounted(async () => {
try {
const { status, response } = await Tables.getTableDll({
uid: props.workspace.uid,
table: props.table,
schema: props.schema
});
if (status === 'success')
createDdl.value = response;
else
addNotification({ status: 'error', message: response });
}
catch (err) {
addNotification({ status: 'error', message: err.stack });
}
});
</script>

View File

@@ -103,6 +103,9 @@
<li class="menu-item">
<a class="c-hand" @click="downloadTable('csv')">CSV</a>
</li>
<li class="menu-item">
<a class="c-hand" @click="downloadTable('php')">{{ t('message.phpArray') }}</a>
</li>
<li class="menu-item">
<a class="c-hand" @click="downloadTable('sql')">SQL INSERT</a>
</li>
@@ -446,7 +449,7 @@ const clear = () => {
clearTabData();
};
const downloadTable = (format: 'csv' | 'json' | 'sql') => {
const downloadTable = (format: 'csv' | 'json' | 'sql' | 'php') => {
queryTable.value.downloadTable(format, `${props.tab.type}-${props.tab.index}`);
};

View File

@@ -177,6 +177,7 @@ import { TableUpdateParams } from 'common/interfaces/tableApis';
import { jsonToSqlInsert } from 'common/libs/sqlUtils';
import { unproxify } from '@/libs/unproxify';
import faker from '@faker-js/faker';
import * as json2php from 'json2php';
const { t } = useI18n();
@@ -528,6 +529,12 @@ const copyRow = (format: string) => {
navigator.clipboard.write(data);
}
else if (format === 'php') {
if (!Array.isArray(contentToCopy)) contentToCopy = [contentToCopy];
const printer = json2php.make({ linebreak: '\n', indent: '\t', shortArraySyntax: true });
const phpString = printer(contentToCopy);
navigator.clipboard.writeText(phpString);
}
};
const createHtmlTable = (tableData: Array<string[]>) => {
@@ -711,7 +718,7 @@ const selectResultset = (index: number) => {
resultsetIndex.value = index;
};
const downloadTable = (format: 'csv' | 'json' | 'sql', table: string, chunks = false) => {
const downloadTable = (format: 'csv' | 'json' | 'sql' | 'php', table: string, chunks = false) => {
if (!sortedResults.value) return;
if (format === 'sql' && !chunks && customizations.value.exportByChunks) {

View File

@@ -31,6 +31,11 @@
<i class="mdi mdi-18px mdi-table-row text-light pr-1" /> {{ t('word.row', selectedRows.length) }} (CSV)
</span>
</div>
<div class="context-element" @click="copyRow('php')">
<span class="d-flex">
<i class="mdi mdi-18px mdi-table-row text-light pr-1" /> {{ t('word.row', selectedRows.length) }} (PHP)
</span>
</div>
<div class="context-element" @click="copyRow('sql')">
<span class="d-flex">
<i class="mdi mdi-18px mdi-table-row text-light pr-1" /> {{ t('word.row', selectedRows.length) }} (SQL INSERT)

View File

@@ -105,6 +105,9 @@
<li class="menu-item">
<a class="c-hand" @click="downloadTable('csv')">CSV</a>
</li>
<li class="menu-item">
<a class="c-hand" @click="downloadTable('php')">{{ t('message.phpArray') }}</a>
</li>
<li class="menu-item">
<a class="c-hand" @click="downloadTable('sql')">SQL INSERT</a>
</li>
@@ -373,7 +376,7 @@ const setRefreshInterval = () => {
}
};
const downloadTable = (format: 'csv' | 'json' | 'sql') => {
const downloadTable = (format: 'csv' | 'json' | 'sql' | 'php') => {
queryTable.value.downloadTable(format, props.table);
};

View File

@@ -149,7 +149,8 @@ export const enUS = {
color: 'Color',
label: 'Label',
icon: 'Icon',
resultsTable: 'Results table'
resultsTable: 'Results table',
ddl: 'DDL'
},
message: {
appWelcome: 'Welcome to Antares SQL Client!',
@@ -342,7 +343,8 @@ export const enUS = {
switchSearchMethod: 'Switch search method',
noResultsPresent: 'No results present',
sqlExportOptions: 'SQL export options',
targetTable: 'Target table'
targetTable: 'Target table',
phpArray: 'PHP array'
},
faker: {
address: 'Address',

View File

@@ -22,7 +22,7 @@ export const itIT = {
settings: 'Impostazioni',
general: 'Generale',
themes: 'Temi',
update: 'Aggiornamento',
update: 'Aggiorna',
about: 'Informazioni',
language: 'Lingua',
version: 'Versione',
@@ -337,7 +337,7 @@ export const itIT = {
executeSelectedQuery: 'Esegui la query selezionata',
defaultCopyType: 'Tipo di copia default',
showTableSize: 'Mostra dimensioni tabella nella sidebar',
showTableSizeDescription: 'Solo MySQL/MariaDB. Abilitare questa opzione può compmpromettere le performance in schemi con molte tabelle.',
showTableSizeDescription: 'Solo MySQL/MariaDB. Abilitare questa opzione può compromettere le performance in schemi con molte tabelle.',
searchForSchemas: 'Cerca schemi',
switchSearchMethod: 'Cambia metodo di ricerca',
noResultsPresent: 'Nessun risultato presente'

View File

@@ -14,12 +14,12 @@ export const ruRU = {
user: 'Пользователь',
password: 'Пароль',
credentials: 'Полномочия',
connect: 'Подключить',
connect: 'Подключиться',
connected: 'Подключено',
disconnect: 'Отключить',
disconnect: 'Отключиться',
disconnected: 'Отключено',
refresh: 'Обновить',
settings: 'Настройка',
settings: 'Настройки',
general: 'Общие',
themes: 'Темы',
update: 'Обновить',
@@ -27,7 +27,7 @@ export const ruRU = {
language: 'Язык',
version: 'Версия',
donate: 'Пожертвование',
run: 'Запуск',
run: 'Выполнить',
schema: 'Схема',
results: 'Результаты',
size: 'Размер',
@@ -42,17 +42,17 @@ export const ruRU = {
connecting: 'Соединение',
name: 'Название',
collation: 'Сопоставление',
clear: 'Очистить',
clear: 'Удалить',
options: 'Опции',
autoRefresh: 'Авто-обновление',
indexes: 'Индексы',
foreignKeys: 'Внешние ключи',
length: 'Длина',
unsigned: 'Неподписанный',
unsigned: 'Беззнаковое',
default: 'По умолчанию',
comment: 'Комментарий',
key: 'Ключ | Ключи',
order: 'Заказ',
order: 'Порядок',
expression: 'Выражение',
autoIncrement: 'Авто-увеличение',
engine: 'Движок',
@@ -60,19 +60,19 @@ export const ruRU = {
approximately: 'Примерно',
total: 'Всего',
table: 'Таблица',
discard: 'Отказать',
discard: 'Отказаться',
stay: 'Оставить',
author: 'Автор',
light: 'Светлая',
dark: 'Темная',
autoCompletion: 'Авто-дополнение',
application: 'Приложение',
editor: 'Реадктор',
view: 'Просмотр',
editor: 'Редактор',
view: 'Представление',
definer: 'Определитель',
algorithm: 'Алгоритм',
trigger: 'Триггер | Триггеры',
storedRoutine: 'Сохраненная процедура | Сохраненные процедуры',
storedRoutine: 'Хранимая процедура | Хранимые процедуры',
scheduler: 'Планировщик | Планировщики',
event: 'Событие',
parameters: 'Параметры',
@@ -85,8 +85,8 @@ export const ruRU = {
timing: 'Сроки',
state: 'Состояние',
execution: 'Выполнение',
starts: 'Начинает',
ends: 'Заканчивает',
starts: 'Начало',
ends: 'Конец',
ssl: 'SSL',
privateKey: 'Закрытый ключ',
certificate: 'Сертификат',
@@ -94,7 +94,7 @@ export const ruRU = {
ciphers: 'Шифры',
upload: 'Загрузки',
browse: 'Обзор',
faker: 'Faker',
faker: 'Генератор данных',
content: 'Содержимое',
cut: 'Вырезать',
copy: 'Копировать',
@@ -106,7 +106,7 @@ export const ruRU = {
scratchpad: 'Заметки',
array: 'Массив',
changelog: 'Журнал изменений',
format: 'Формат',
format: 'Отформатировать',
sshTunnel: 'SSH туннель',
structure: 'Структура',
small: 'Малый',
@@ -117,47 +117,57 @@ export const ruRU = {
triggerFunction: 'Функция запуска | Функции запуска',
all: 'Все',
duplicate: 'Дубликат',
routine: 'Порядок',
routine: 'Хранимая процедура',
new: 'Новый',
history: 'История',
select: 'Выбрать',
passphrase: 'Кодовая фраза',
filter: 'Фильтр',
change: 'Изменить',
views: 'Просмотры',
views: 'Представления',
triggers: 'Триггеры',
routines: 'Порядок',
routines: 'Хранимые процедуры',
functions: 'Функции',
schedulers: 'Планировщики',
includes: 'Включает',
drop: 'Сбросить',
includes: 'Включая',
drop: 'Удалить',
completed: 'Завершено',
aborted: 'Aborted',
disabled: 'Прервано',
aborted: 'Прервано',
disabled: 'Отключено',
enable: 'Включить',
disable: 'Выключить',
commit: 'Подтвердить',
rollback: 'Отмена',
rollback: 'Откатить',
connectionString: 'Строка подключения',
contributors: 'Участники'
contributors: 'Участники',
pin: 'Закрепить',
unpin: 'Открепить',
console: 'Консоль',
shortcuts: 'Горячие клавиши',
folder: 'Директория | Директории',
appearence: 'Внешний вид',
color: 'Цвет',
label: 'Метка',
icon: 'Иконка',
resultsTable: 'Таблица с результатом'
},
message: {
appWelcome: 'Приветсвуем в SQL клиенте Antares!',
appWelcome: 'Приветствуем в SQL клиенте Antares!',
appFirstStep: 'Ваш первый шаг: создать новое подключение с БД.',
addConnection: 'Добавить подключение',
createConnection: 'Создать подключение',
createNewConnection: 'Созадть новое подключение',
createNewConnection: 'Создать новое подключение',
askCredentials: 'Спрашивать учетные данные',
testConnection: 'Тестирование подключения',
editConnection: 'Редактирование подключения',
testConnection: 'Тест подключения',
editConnection: 'Редактировать подключение',
deleteConnection: 'Удалить подключение',
deleteCorfirm: 'Подтверждаете ли вы отмену',
deleteCorfirm: 'Подтверждаете ли вы удаление',
connectionSuccessfullyMade: 'Соединение успешно установлено!',
madeWithJS: 'Сделано с 💛 и JavaScript!',
checkForUpdates: 'Проверить обновления',
noUpdatesAvailable: 'Обновлений не найдено',
checkingForUpdate: роверить обновления',
checkFailure: 'Проверка не удалась, пожалуйста, попробуйте позже',
checkingForUpdate: оиск обновлений',
checkFailure: 'Не удалось проверить обновления, пожалуйста, попробуйте позже',
updateAvailable: 'Доступно обновление',
downloadingUpdate: 'Скачать обновление',
updateDownloaded: 'Обновление скачано',
@@ -174,10 +184,10 @@ export const ruRU = {
affectedRows: 'Задействовано строк',
createNewDatabase: 'Создать новую БД',
databaseName: 'Название БД',
serverDefault: 'Сервер по умолчанию',
serverDefault: 'По-умолчанию на сервере',
deleteDatabase: 'Удалить БД',
editDatabase: 'Редактировать БД',
clearChanges: 'Очистить изменения',
clearChanges: 'Удалить изменения',
addNewField: 'Добавить новое поле',
manageIndexes: 'Управление индексами',
manageForeignKeys: 'Управление внешними ключами',
@@ -189,7 +199,7 @@ export const ruRU = {
createNewIndex: 'Создать новый индекс',
addToIndex: 'Добавить индекс',
createNewTable: 'Создать новую таблицу',
emptyTable: 'Пустая таблица',
emptyTable: 'Очистить таблицу',
deleteTable: 'Удалить таблицу',
emptyCorfirm: 'Подтверждаете очистку?',
unsavedChanges: 'Несохраненные изменения',
@@ -203,23 +213,23 @@ export const ruRU = {
invalidDefault: 'Недопустимое значение',
onDelete: 'При удалении',
applicationTheme: 'Тема приложения',
editorTheme: 'Редактировать Тему',
editorTheme: 'Редактировать тему',
wrapLongLines: 'Перенос длинных строк',
selectStatement: 'Оператор выбора',
triggerStatement: 'Оператор триггера',
sqlSecurity: 'SQL безопасность',
updateOption: 'Опции обновления',
deleteView: 'Удалить просмотр',
createNewView: 'Создать новый просмотр',
deleteView: 'Удалить представление',
createNewView: 'Создать новое представление',
deleteTrigger: 'Удалить триггер',
createNewTrigger: 'Создать новый триггер',
currentUser: 'Текущий пользователь',
routineBody: 'Routine body',
routineBody: 'Тело процедуры',
dataAccess: 'Доступ к данным',
thereAreNoParameters: 'Там нет никаких параметров',
thereAreNoParameters: 'Параметры отсутствуют',
createNewParameter: 'Создать новый параметр',
createNewRoutine: 'Создание новой сохраненной процедуры',
deleteRoutine: 'Удаление сохраненной процедуры',
createNewRoutine: 'Создание новой хранимой процедуры',
deleteRoutine: 'Удаление хранимой процедуры',
functionBody: 'Тело функции',
createNewFunction: 'Создать новую функцию',
deleteFunction: 'Удалить функцию',
@@ -248,37 +258,37 @@ export const ruRU = {
dataTabPageSize: 'Размер страницы вкладки ДАННЫЕ',
enableSsh: 'Включить SSH',
pageNumber: 'Номер страницы',
duplicateTable: 'Дубликат таблицы',
duplicateTable: 'Клонировать таблицу',
noOpenTabs: 'Открытых вкладок нет, перейдите по левой панели или:',
noSchema: 'Нет схемы',
restorePreviourSession: 'Восстановить предыдущую сессию',
runQuery: 'Запуск очереди',
runQuery: 'Выполнить запрос',
thereAreNoTableFields: 'В таблице нет полей',
newTable: 'Новая таблица',
newView: 'Новый просмотр',
newView: 'Новое представление',
newTrigger: 'Новый триггер',
newRoutine: 'New routine',
newRoutine: 'Новая хранимая процедура',
newFunction: 'Новая функция',
newScheduler: 'Новый планировщик',
newTriggerFunction: 'Новая функция триггера',
thereIsNoQueriesYet: 'Пока нет никаких запросов',
thereIsNoQueriesYet: 'Запросы пока отсутствуют',
searchForQueries: 'Поиск по запросам',
killProcess: 'Убить процесс',
closeTab: 'Закрыть вкладку',
exportSchema: 'Экспорт схемы',
importSchema: 'Импорт схемы',
directoryPath: 'Путь к каталогу',
newInserStmtEvery: 'New INSERT statement every',
newInserStmtEvery: 'Новый INSERT оператор для каждых',
processingTableExport: 'Обработка {table}',
fechingTableExport: 'Получение данных с {table}',
fechingTableExport: 'Получение данных из {table}',
writingTableExport: 'Запись данных в {table}',
checkAllTables: 'Проверить все таблицы',
checkAllTables: 'Выбрать у всех таблицы',
uncheckAllTables: 'Убрать со всех таблиц',
goToDownloadPage: 'Перейти на страницу для загрузки',
goToDownloadPage: 'Перейти на страницу загрузки',
readOnlyMode: 'Режим только чтение',
killQuery: 'Убить запрос',
insertRow: 'Вставить строку | Вставить строки',
commitMode: 'Режим подтверждения',
commitMode: 'Режим подтверждения транзакций',
autoCommit: 'Авто-подтверждение',
manualCommit: 'Ручное подтверждение',
actionSuccessful: '{action} успешно',
@@ -290,7 +300,49 @@ export const ruRU = {
disableBlur: 'Отключить размытие',
untrustedConnection: 'Ненадежное соединение',
missingOrIncompleteTranslation: 'Отсутствующий или неполный перевод?',
findOutHowToContribute: 'Узнайте, как внести свой вклад'
findOutHowToContribute: 'Узнайте, как внести свой вклад',
disableFKChecks: 'Отключить проверку внешних ключей',
allConnections: 'Все соединения',
searchForConnections: 'Поиск соединений',
disableScratchpad: 'Отключить заметки',
reportABug: 'Сообщить о баге',
nextTab: 'Следующая вкладка',
previousTab: 'Предыдущая вкладка',
selectTabNumber: 'Выбрать вкладку под номером {param}',
toggleConsole: 'Переключиться на консоль',
addShortcut: 'Добавить горячие клавиши',
editShortcut: 'Изменить горячие клавиши',
deleteShortcut: 'Удалить горячие клавиши',
restoreDefaults: 'Восстановить по-умолчанию',
restoreDefaultsQuestion: 'Вы подтверждаете восстановление значений по-умолчанию?',
registerAShortcut: 'Зарегистрировать горячие клавиши',
invalidShortcutMessage: 'Невозможно использовать эту комбинацию, попробуйте ещё',
shortcutAlreadyExists: 'Такая комбинация уже существует',
saveContent: 'Сохранить содержимое',
openAllConnections: 'Открыть все соединения',
openSettings: 'Открыть настройки',
openScratchpad: 'Открыть заметки',
runOrReload: 'Выполнить или обновить',
formatQuery: 'Отформатировать запрос',
queryHistory: 'История запросов',
clearQuery: 'Очистить запрос',
openFilter: 'Открыть фильтр',
nextResultsPage: 'Следующая страница',
previousResultsPage: 'Предыдущая страница',
fillCell: 'Заполнить ячейку',
editFolder: 'Изменить директорию',
folderName: 'Название директории',
deleteFolder: 'Удалить директорию',
editConnectionAppearence: 'Изменить внешний вид соединения',
executeSelectedQuery: 'Выполнить выделенный запрос',
defaultCopyType: 'Тип копирования по-умолчанию',
showTableSize: 'Показывать размер таблицы в сайдбаре',
showTableSizeDescription: 'Только MySQL/MariaDB. Включение этого параметра может повлиять на производительность схемы с большим количеством таблиц.',
searchForSchemas: 'Поиск схем',
switchSearchMethod: 'Переключить способ поиска',
noResultsPresent: 'Данные отсутствуют',
sqlExportOptions: 'Опции SQL экспорта',
targetTable: 'Целевая таблица'
},
faker: {
address: 'Адрес',
@@ -309,7 +361,7 @@ export const ruRU = {
random: 'Случайный',
system: 'Система',
time: 'Время',
vehicle: 'Vehicle',
vehicle: 'Средство передвижения',
zipCode: 'Почтовый код',
zipCodeByState: 'Почтовый код города',
city: 'Город',
@@ -323,8 +375,8 @@ export const ruRU = {
county: 'Округ',
country: 'Страна',
countryCode: 'Код страны',
state: 'Штат',
stateAbbr: 'Аббревиатура штата',
state: 'Область',
stateAbbr: 'Аббревиатура области',
latitude: 'Широта',
longitude: 'Долгота',
direction: 'Направление',
@@ -336,8 +388,8 @@ export const ruRU = {
department: 'Отдел',
productName: 'Имя продукта',
price: 'Прайс',
productAdjective: 'Product adjective',
productMaterial: 'Product material',
productAdjective: 'Относящееся к продукту',
productMaterial: 'Материал продукта',
product: 'Продукт',
productDescription: 'Описание продукта',
suffixes: 'Суфиксы',
@@ -356,15 +408,16 @@ export const ruRU = {
collation: 'Сопоставление',
engine: 'Движок',
past: 'Прошлое',
now: 'Сейчас',
future: 'Будущее',
between: 'Между',
recent: 'Недавнее',
soon: 'Вскоре',
month: 'Месяц',
weekday: 'Будний день',
weekday: 'День недели',
account: 'Аккаунт',
accountName: 'Имя аккаунта',
routingNumber: 'Routing number',
routingNumber: 'Номер маршрута',
mask: 'Маска',
amount: 'Сумма',
transactionType: 'Тип транзакции',
@@ -380,9 +433,9 @@ export const ruRU = {
bic: 'Bic',
transactionDescription: 'Описание транзакции',
branch: 'Ветка',
commitEntry: 'Подтвердить запись',
commitMessage: 'Подтвердить сообщение',
commitSha: 'Подтвердить SHA',
commitEntry: 'Коммит',
commitMessage: 'Сообщение коммита',
commitSha: 'SHA коммита',
shortSha: 'Короткий SHA',
abbreviation: 'Сокращение',
adjective: 'Прилагательное',
@@ -402,21 +455,21 @@ export const ruRU = {
ip: 'Ip',
ipv6: 'Ipv6',
userAgent: 'User agent',
mac: 'Мак-адрес',
mac: 'MAC-адрес',
password: 'Пароль',
word: 'Слово',
words: 'Слова',
sentence: 'Предложение',
slug: 'Slug',
sentences: 'Sentences',
sentences: 'Предложения',
paragraph: 'Параграф',
paragraphs: 'Параграфы',
text: 'Текст',
lines: 'Линии',
genre: 'Жанр',
firstName: 'Фамилия',
lastName: 'Имя',
middleName: 'Среднее имя',
firstName: 'Имя',
lastName: 'Фамилия',
middleName: 'Отчество',
findName: 'Полное имя',
jobTitle: 'Название задания',
gender: 'Пол',
@@ -427,24 +480,24 @@ export const ruRU = {
jobArea: 'Область задания',
jobType: 'Тип задания',
phoneNumber: 'Номер телефона',
phoneNumberFormat: 'Формат номера',
phoneNumberFormat: 'Формат номера телефона',
phoneFormats: 'Формат номеров телефона',
number: 'Номер',
float: 'Дробное число',
arrayElement: 'Элемент массива',
arrayElements: 'Элементы массива',
objectElement: 'Объект элемента',
objectElement: 'Элемент объекта',
uuid: 'Uuid',
boolean: 'Логический',
image: 'Изображение',
locale: 'Локаль',
alpha: 'Альфа',
alphaNumeric: 'Буквенно-Цифровой',
alpha: 'Буквенный',
alphaNumeric: 'Буквенно-цифровой',
hexaDecimal: 'Шестнадцатеричный',
fileName: 'Имя файла',
commonFileName: 'Общее имя файла',
mimeType: 'Mime тип',
commonFileType: 'Общий тип файло',
mimeType: 'Mime-тип',
commonFileType: 'Общий тип файлов',
commonFileExt: 'Общее расширение файлов',
fileType: 'Тип файла',
fileExt: 'Расширение файла',

View File

@@ -35,6 +35,10 @@ export default class {
return ipcRenderer.invoke('get-table-indexes', unproxify(params));
}
static getTableDll (params: { uid: string; schema: string; table: string }): Promise<IpcResponse<string>> {
return ipcRenderer.invoke('get-table-ddl', unproxify(params));
}
static getKeyUsage (params: { uid: string; schema: string; table: string }): Promise<IpcResponse> {
return ipcRenderer.invoke('get-key-usage', unproxify(params));
}

View File

@@ -1,8 +1,9 @@
import { ClientCode } from 'common/interfaces/antares';
import { jsonToSqlInsert } from 'common/libs/sqlUtils';
import * as json2php from 'json2php';
export const exportRows = (args: {
type: 'csv' | 'json'| 'sql';
type: 'csv' | 'json'| 'sql' | 'php';
content: object[];
table: string;
client?: ClientCode;
@@ -48,6 +49,13 @@ export const exportRows = (args: {
content = sql;
break;
}
case 'php': {
mime = 'application/x-httpd-php';
const printer = json2php.make({ linebreak: '\n', indent: '\t', shortArraySyntax: true });
content = printer(args.content);
content = `<?php\n$${(args.sqlOptions?.targetTable || args.table).replaceAll('-', '_')} = ${content};`;
break;
}
case 'json':
mime = 'application/json';
content = JSON.stringify(args.content, null, 3);

View File

@@ -2,6 +2,7 @@
/* eslint-disable @typescript-eslint/ban-types */
declare module '@/App.vue';
declare module 'v-mask';
declare module 'json2php';
declare module 'vuedraggable' {// <- to export as default
const draggableComponent: import('vue').DefineComponent<{
list: {