All Projects → vitaly-t → Pg Minify

vitaly-t / Pg Minify

Minifies PostgreSQL scripts.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pg Minify

Go Starter
An opinionated production-ready SQL-/Swagger-first RESTful JSON API written in Go, highly integrated with VSCode DevContainers by allaboutapps.
Stars: ✭ 37 (+0%)
Mutual labels:  sql, postgresql
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (+1972.97%)
Mutual labels:  sql, postgresql
Db Dumper
Dump the contents of a database
Stars: ✭ 744 (+1910.81%)
Mutual labels:  sql, postgresql
Pmacct
pmacct is a small set of multi-purpose passive network monitoring tools [NetFlow IPFIX sFlow libpcap BGP BMP RPKI IGP Streaming Telemetry].
Stars: ✭ 677 (+1729.73%)
Mutual labels:  sql, postgresql
Massive
A Module for Utilizing MassiveJS with NestJS
Stars: ✭ 27 (-27.03%)
Mutual labels:  sql, postgresql
Sequelize
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+68608.11%)
Mutual labels:  sql, postgresql
Azuredatastudio
Azure Data Studio is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.
Stars: ✭ 6,605 (+17751.35%)
Mutual labels:  sql, postgresql
Lucid
AdonisJS official SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
Stars: ✭ 613 (+1556.76%)
Mutual labels:  sql, postgresql
Efcore.pg
Entity Framework Core provider for PostgreSQL
Stars: ✭ 838 (+2164.86%)
Mutual labels:  sql, postgresql
Fluentpdo
A PHP SQL query builder using PDO
Stars: ✭ 783 (+2016.22%)
Mutual labels:  sql, postgresql
Sqlancer
Detecting Logic Bugs in DBMS
Stars: ✭ 672 (+1716.22%)
Mutual labels:  sql, postgresql
Eosio sql plugin
EOSIO sql database plugin
Stars: ✭ 21 (-43.24%)
Mutual labels:  sql, postgresql
Rezoom.sql
Statically typechecks a common SQL dialect and translates it to various RDBMS backends
Stars: ✭ 621 (+1578.38%)
Mutual labels:  sql, postgresql
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+1902.7%)
Mutual labels:  sql, postgresql
Beekeeper Studio
Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more. Linux, MacOS, and Windows.
Stars: ✭ 8,053 (+21664.86%)
Mutual labels:  sql, postgresql
Usql
Universal command-line interface for SQL databases
Stars: ✭ 6,869 (+18464.86%)
Mutual labels:  sql, postgresql
Hibernate Springboot
Collection of best practices for Java persistence performance in Spring Boot applications
Stars: ✭ 589 (+1491.89%)
Mutual labels:  sql, postgresql
Trdsql
CLI tool that can execute SQL queries on CSV, LTSV, JSON and TBLN. Can output to various formats.
Stars: ✭ 593 (+1502.7%)
Mutual labels:  sql, postgresql
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+1994.59%)
Mutual labels:  sql, postgresql
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+2164.86%)
Mutual labels:  sql, postgresql

pg-minify

Minifies PostgreSQL scripts, reducing the IO usage.

Build Status Coverage Status Join the chat at https://gitter.im/vitaly-t/pg-minify

Features:

  • Removes /*multi-line*/ (including nested) and --single-line comments
  • Preserves special/copyright multi-line comments that start with /*!
  • Concatenates multi-line strings into a single line with \n
  • Fixes multi-line text, prefixing it with E where needed
  • Removes redundant line gaps: line breaks, tabs and spaces
  • Provides basic parsing and error detection for invalid SQL
  • Flattens the resulting script into a single line
  • Optionally, compresses SQL for minimum space

Installing

$ npm install pg-minify

Usage

const minify = require('pg-minify');

const sql = 'SELECT 1; -- comments';

minify(sql); //=> SELECT 1;

with compression (removes all unnecessary spaces):

const sql = 'SELECT * FROM "table" WHERE col = 123; -- comments';

minify(sql, {compress: true});
//=> SELECT*FROM"table"WHERE col=123;

The library's distribution includes TypeScript declarations.

Error Handling

SQLParsingError is thrown on failed SQL parsing:

try {
    minify('SELECT \'1');
} catch (error) {
    // error is minify.SQLParsingError instance
    // error.message:
    // Error parsing SQL at {line:1,col:8}: Unclosed text block.
}

API

minify(sql, [options]) ⇒ String

Minifies SQL into a single line, according to the options.

options.compress ⇒ Boolean

Compresses / uglifies the SQL to its bare minimum, by removing all unnecessary spaces.

  • false (default) - keeps minimum spaces, for easier read
  • true - removes all unnecessary spaces

See also: SQL Compression.

options.removeAll ⇒ Boolean

Removes everything, i.e. special/copyright multi-line comments that start with /*! will be removed as well.

Testing

First, clone the repository and install DEV dependencies.

$ npm test

Testing with coverage:

$ npm run coverage

License

Copyright © 2020 Vitaly Tomilov; Released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].