百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
N

niceql

> 编程语言
开源

niceql gem 仓库。ruby 中的漂亮、彩色的 SQL 格式化。

326 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

niceql gem 仓库。ruby 中的漂亮、彩色的 SQL 格式化。

Niceql

ATTENTION: After ver 0.5.0 the ActiveRecord integration is provided via standalone gem: rails_sql_prettifier!

This is a small, nice, simple and zero dependency solution for SQL prettifying for Ruby. It can be used in an irb console without any dependencies ( run bin/console and look for examples ).

Any reasonable suggestions are welcome.

Before/After

SQL prettifier:

PG errors prettifier

before:

after:

Installation

Add this line to your application's Gemfile:

ruby
gem 'niceql'

And then execute:

$ bundle
# if you are using rails, you may want to install niceql config:
rails g niceql:install 

Or install it yourself as:

$ gem install niceql

Configuration

…

Usage

With ActiveRecord ( you need rails_sql_prettifier for that! )

ruby
  # puts colorized and formatted corresponding SQL query
  Model.scope.niceql
  
  # only formatting without colorization, you can run output of to_niceql as a SQL query in connection.execute  
  Model.scope.to_niceql
  
  # prettify PG errors if scope runs with any 
  Model.scope_with_err.exec_niceql 

Without ActiveRecord

…

Customizing colors

If your console support more colors or different schemes, or if you prefer different colorization, then you can override ColorizeString methods. Current colors are selected with dark and white console themes in mind, so a niceql colorization works good for dark, and good enough for white.

Limitations

Right now gem detects only uppercased form of verbs with simple indentation and parsing options.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alekseyl/niceql.

License

The gem is available as open source under the terms of the MIT License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言