Skip to content

A web app which can be used to query one or more SQL databases.

License

Notifications You must be signed in to change notification settings

nicholasdower/sqlui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLUI (/ˈskwiːli/)

Intro

A web app which can be used to query one or more SQL databases.

Contents

Features

  • Query
    • Execute queries
    • Autocomplete keywords, table names, columns
    • Configure autocomplete of frequently used join statements
    • Configure autocomplete of frequently used table aliases
    • Save to file/clipboard
    • Executing saved queries from GitHub
    • Cell links.
  • Graph results (WIP)
  • Share queries via URL
  • View database details
    • List databases
    • List tables
    • View table stats
    • View column details
    • View index details
  • Export metrics to Prometheus (WIP)
  • Report errors to Airbrake

Screenshots

Usage

Create a config file

See development_config.yml for an example.

# App Configuration
name:          SQLUI                            # Server display name to be used in the UI.
port:          8080                             # App port.
environment:   development                      # App environment.
base_url_path: /sqlui                           # URL path used as the base for all app URLs.

# Database Configurations
databases:                                      # Map of database configurations.
  seinfeld:                                     # Database configuration name.
    display_name: Seinfeld                      # User-facing name.
    description:  A database about nothing.     # User-facing description.
    url_path:     seinfeld                      # Relative URL path used to access this database.

    # Connection Configuration
    client_params:                              # Params for the MySQL client.
      database: seinfeld                        # Optional database name.
      username: newman                          # Database username.
      password: drakescoffeecake                # Database password.
      port:     3306                            # Database port.
      host:     127.0.0.1                       # Database host.

    # Saved File Configuration
    author:                                     # Details used when authoring a commit.
      name: 'SQLUI'
      email: [email protected]
    token:  ghp_SomEt0k3N                       # GitHub personal access token with "repo" scope.
    owner:  nicholasdower                       # Repo owner.
    repo:   sqlui                               # Repo name.
    branch: master                              # Branch.
    regex:  ^sql/.*[.]sql$                      # Regex used to match files.

    # Table Configurations (Optional)
    tables:                                     # Map of table configurations.
      characters:                               # Table name.
        alias: c                                # Default table alias.
        boost: 1                                # Auto-complete boost. -99 to 99.
      [...]

    # Column Configurations (Optional)
    columns:                                    # Map of column configurations.
      name:                                     # Column name.
        links:                                  # Optional map of cell links.
          google:                               # Link configuration name.
            short_name: G                       # Link short name. Displayed within the cell.
            long_name:  Google                  # Link long name. Displayed on hover.
            template:   google.com/search?q={*} # Link URL. Use {*} as a placeholder.
          [...]

    # Join Configurations (Optional)
    joins:                                      # Map of join configurations.
      actors_to_charactors:                     # Join configuration name.
        label: 'actors to characters'           # Join label. Displayed in autocomplete dropdown.
        apply: 'actors a ON a.id = c.actor_id'  # Join statement.
      [...]
  [...]

Install the Gem or add it to your Gemfile

gem install 'sqlui'

or

gem 'sqlui'

Run the gem directly or via bundle if using a Gemfile

sqlui <config-file>

or

bundle exec sqlui <config-file>

Development

Default Setup

By default all building, running and testing is done in Docker containers.

Install Docker

See https://docs.docker.com/get-docker/

Start the database and server

make start

Visit http://localhost:8080/sqlui

Run the tests

make test

Running The Server & Tests Outside of Docker

It is also possible to run the server and unit tests without Docker. Docker is still used for MySQL and browser tests.

Install rvm (Ruby Version Manager)

See https://rvm.io/rvm/install

Install Ruby

rvm install ruby-3.0.0
rvm use

Install nvm (Node Version Manager)

See https://github.com/nvm-sh/nvm#installing-and-updating.

Install Node

nvm install 19.0.0
nvm use

Start the database and server

make start-local

Visit http://localhost:8080/sqlui

Install Chromedriver

See https://chromedriver.chromium.org/getting-started

Run the tests

make test-local