add different clients support

This commit is contained in:
Guy Ben-Aharon
2024-09-02 18:46:15 +03:00
committed by Guy Ben-Aharon
parent 1fbf7cc677
commit eee9832fe1
11 changed files with 194 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
import { DatabaseClient } from '@/lib/domain/database-clients';
import {
DatabaseEdition,
databaseEditionToLabelMap,
@@ -6,6 +7,7 @@ import {
export const getPostgresQuery = (
options: {
databaseEdition?: DatabaseEdition;
databaseClient?: DatabaseClient;
} = {}
): string => {
const databaseEdition: DatabaseEdition | undefined =
@@ -227,5 +229,11 @@ SELECT CONCAT('{ "fk_info": [', COALESCE(fk_metadata, ''),
FROM fk_info${databaseEdition ? '_' + databaseEdition : ''}, pk_info, cols, indexes_metadata, tbls, config, views;
`;
if (options.databaseClient === DatabaseClient.POSTGRESQL_PSQL) {
return `psql -h HOST_NAME -p PORT -U USER_NAME -d DATABASE_NAME -c "
${query}
" -t -A | pbcopy; LG='\\033[0;32m'; NC='\\033[0m'; echo "You got the resultset ($(pbpaste | wc -c | xargs) characters) in Copy/Paste. \${LG}Go back & paste in ChartDB :)\${NC}";`;
}
return query;
};