GithubHelp home page GithubHelp logo

frectonz / sql-studio Goto Github PK

View Code? Open in Web Editor NEW
1.9K 8.0 42.0 2.97 MB

SQL Database Explorer [SQLite, libSQL, PostgreSQL, MySQL/MariaDB, DuckDB, ClickHouse]

Home Page: https://sql-studio.onrender.com/

License: MIT License

Nix 1.38% Rust 47.98% JavaScript 1.31% HTML 0.37% TypeScript 47.71% CSS 1.25%
rust sqlite sqlite-browser libsql postgresql mariadb mysql duckdb

sql-studio's Introduction

banner

SQL Studio

Single binary, single command SQL database explorer. SQL studio supports SQLite, libSQL, PostgreSQL, MySQL and DuckDB.

Local SQLite DB File

sql-studio sqlite [sqlite_db]

Remote libSQL Server

sql-studio libsql [url] [auth_token]

PostgreSQL Server

sql-studio postgres [url]

MySQL/MariaDB Server

sql-studio mysql [url]

Local DuckDB File

sql-studio duckdb [duckdb_file]

ClickHouse Server (Partial Support)

sql-studio clickhouse [URL] [USER] [PASSWORD] [DATABASE]

Features

  • Overview page with common metadata.
  • Tables page with each table's metadata.
  • Queries page with more access to your db.
  • Infinite scroll rows view.

More features available on the releases page.

Screenshots

Overview Page

overview overview dark

Tables Page

tables tables dark

Query Page

query query dark

Installation

Install prebuilt binaries via shell script (MacOS and Linux)

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/frectonz/sql-studio/releases/download/0.1.26/sql-studio-installer.sh | sh

Install prebuilt binaries via powershell script

powershell -c "irm https://github.com/frectonz/sql-studio/releases/download/0.1.26/sql-studio-installer.ps1 | iex"

Updating

sql-studio-update

Nix

nix shell github:frectonz/sql-studio

Contributing

Before executing cargo run you need to build the UI because the rust app statically embedded the UI files in the binary.

git clone [email protected]:frectonz/sql-studio.git
cd sql-studio
nix develop # if you use nix
cd ui
npm install
npm run build
cd ..
cargo run

sql-studio's People

Contributors

charlie-collard avatar dgcp3 avatar frectonz avatar jamietanna avatar kinfe123 avatar miki-tebe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sql-studio's Issues

Add requirements section in readme

I've noticed that the install script requires cargo to be installed which requires rust to be installed, why not to add this in requirements section before dive into installation and get error like my case !?

Postgresql connection issue

Hi,

just wanted to try the sql-stido with my running postgres-docker-instance locally. The docker postgres is running and used by other local running apps (go / rust) without any problems.

I'm trying to start sql-studio as follows

sql-studio postgres postgres://username123:pasword123@localhost:5432/postgres?sslmode=disable
zsh: no matches found: postgres://username123:pasword123@localhost:5432/postgres?sslmode=disable

Suprisingly, the following connection string works:

sql-studio postgres postgres://username123:pasword123@localhost:5432/postgres

Postgres schemas

Postgres has a feature called schemas which is a logical container within a database that holds tables, views, indexes, sequences, functions, and other database objects, when I use sql-studio with my db which contains a lot of schemas it shows only the public schema !
Is there an option to see other schemas or it's not supported for now ?

Allow serving requests from a subpath (for reverse proxying)

I'm looking at using this project as part of another (https://dmd.tanna.dev) in which I'm looking to reverse proxy this project under a sub-path.

This can be seen in i.e. https://dependency-management-data-example.fly.dev/datasette/dmd?sql=select+*+from+metadata which reverse proxies from the datasette process' HTTP server under a sub-path.

I believe this will require changes in this project to enable it, by injecting in the subpath to i.e. /assets URLs, which would then be i.e. /sql-studio/assets

Introduce an `sql` query parameter for queries

One of the things that's good about https://datasette.io - an alternative to this project - is the way that SQL queries construct a shareable URL such as https://dependency-management-data-example.fly.dev/datasette/dmd?sql=select+*+from+metadata

It'd be handy if we had the same functionality here, which would allow sharing URLs for i.e. a centrally deployed version of sql-studio

Ideally this would update as the input changes, so the URL is always in-sync with the query being executed

Improve rendering of incredibly wide tables

I've got a table that has 26 columns (:face_with_peeking_eye:) and when opening it (with 0.1.17) I see:

2024-06-28-085431_1811x67_scrot

I wonder if we should:

  • add a tooltip (title attribute) to each column, to indicate what the text is, in case it's truncated
  • allow scrolling horizontally

Thoughts?

Wrap it with docker

Hi, it is good idea to wrap your code with docker container, to let world to try your solution.

The instructions for a docker is a modern standard of distribution for a web software.

It's pretty hard to build all the thing on my PC to just see every solution on the github, so me and lot of another people will just skip a repo with instructions "how to build" and with no instructions "how to run right here right now with docker".

Bug? Compiling from source leads to segfault in `duckdb-rs`

I've noticed that I seem to be getting the following error when building from source:

warning: [email protected]: /usr/include/c++/13.2.1/type_traits:286:13: internal compiler error: Segmentation fault
warning: [email protected]:   286 |     >::type __is_complete_or_unbounded(_TypeIdentity)
warning: [email protected]:       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
warning: [email protected]: 0x1ad33c8 internal_error(char const*, ...)

Full log: https://gist.github.com/jamietanna/5e9daab169ee5c587c9b5404089d5886

Not sure if it's just my machine possibly, or if there's something I can do to debug? (I'm not a Rust dev)

Running `sql-studio` on a distroless image

This is a tracking image where I'm looking at how I'd be able to run this with as-lightweight-as-possible a Docker image.

Related: #32

Chainguard static image

FROM cgr.dev/chainguard/static:latest

COPY sql-studio /

And then when we run this image, we see:

exec /sql-studio: no such file or directory

Chainguard static glibc image

FROM cgr.dev/chainguard/static:latest-glibc

COPY sql-studio /

And then when we run this image, we see:

exec /sql-studio: no such file or directory

Google distroless static glibc image

FROM gcr.io/distroless/static-debian12:latest

COPY sql-studio /

And then when we run this image, we see:

exec /sql-studio: no such file or directory

Ubuntu 22.04 Problem [libssl]

Hello, amazing project!

I tried locally and got the following error:

image

For me the default is libssl3, and for security reasons I sticking to it. Do you have some info about? Is something that you saw before? Need some help?

UPDATE: Building locally, runs fine! The executable provided by the install command is probably targeting some old debian, ubuntu (?) with outdated libssl.

Thx!

Tricky table name causes error

I tried to use this with my SQLite database from one of my projects and got this error:

2024-06-16T23:41:39.610846Z ERROR sqlite_studio::handlers: error while getting database overview: Rusqlite("near "2": syntax error in SELECT count(*) FROM 2-categories at offset 21")

I think that this is caused by the table name 2-categories. It's legal but requires extra quotes. I confirmed this with the SQLite REPL:

sqlite> select count(*) from 2-categories;
Parse error: near "2": syntax error
  select count(*) from 2-categories;
                       ^--- error here
sqlite> select count(*) from '2-categories';
31

Set an upper bound (maybe via config) for the `limit` of rows

When running this against a large database (i.e. ~1M rows in a specific table) and performing a query such as:

-- where renovate is the table with ~1M rows
select * from renovate

The application locks up.

It may be worth having a limit, which is maybe configurable using a command-line argument, as it's unlikely a user will be wanting the full 1,000,000 rows? It's nice that we do get all the rows instead of truncating it early, but it may be useful to have available as a limited thing, especially for large databases, or centrally deployed instances of sql-studio

Rusqlite("unknown tokenizer: icu") while opening a sqlite database generated from Android

2024-07-06T03:42:35.648701Z  INFO sql_studio::sqlite: found 13 tables in C:\Users\o_oll\databases\ama-database
2024-07-06T03:42:35.692703Z  INFO sql_studio: tried to open in browser: Ok(())
2024-07-06T03:42:35.693585Z  INFO Server::run{addr=127.0.0.1:3030}: warp::server: listening on http://127.0.0.1:3030
2024-07-06T03:42:36.687915Z ERROR sql_studio::handlers: error while getting database overview: Rusqlite("unknown tokenizer: icu")

This file is generated from Android and uses Fts4 with the icu tokenizer configuration.

Support multi-line output of queries

I.e. via this query I'm looking at using group_concat with SQLite to produce a newline-delimited output like:

select
  json_each.key as configuration_key,
  group_concat(
    platform || '/' || organisation || '/' || repo,
    char(13)
  ) as repos,
  count(*) as num_repos_with_config,
  total_repos.c as total_repos
from
  renovate_configs,
  json_each(renovate_configs.config),
  (
    select
      count(*) as c
    from
      renovate_configs
  ) as total_repos
group by
  json_each.key

Which renders like so with sqlite3:

2024-06-28-090148_873x382_scrot

However, when using sql-studio, we see:

2024-06-28-090229_1774x182_scrot

Customize Overview

It would be nice if could have the ability to have customized overview instead of the default one. A possible implementation can be a yaml or json file containing data on how to query and description. Example:

overview:
  title: "Analytics Dashboard"
  layout:
    - title: "Summary"
      total_users:
        type: "number"
        title: "Total Users"
        value: "{{ queries.total_users }}"
        previous_value: "{{ queries.previous_total_users }}"
        description: "The total number of users"
        icon: "user"
      growth_rate:
        type: "percentage"
        title: "Growth Rate"
        value: "{{ queries.growth_rate }}"
        previous_value: "{{ queries.previous_growth_rate }}"
        description: "The growth rate compared to last month"
        icon: "chart-line"
      active_users:
        type: "number"
        title: "Active Users"
        value: "{{ queries.active_users }}"
        previous_value: "{{ queries.previous_active_users }}"
        description: "Number of active users"
        icon: "user-check"

    - title: "Analytics"
      users_by_age:
        type: "chart"
        title: "Users by Age"
        x_axis: "Age"
        y_axis: "Number of Users"
        data: "{{ queries.users_by_age }}"
        description: "Distribution of users by age"
        chart_type: "bar"
      population_by_year:
        type: "chart"
        title: "Population by Year"
        x_axis: "Year"
        y_axis: "Population"
        data: "{{ queries.population_by_year }}"
        description: "Population trends over the years"
        chart_type: "line"

    - title: "Tables"
      first_5_last_items:
        type: "list"
        title: "First 5 Last Items"
        items: "{{ queries.first_5_last_items }}"
        description: "List of the first 5 last items"
        icon: "list"
      top_10_loyal_users:
        type: "list"
        title: "Top 10 Loyal Users"
        items: "{{ queries.top_10_loyal_users }}"
        description: "List of the top 10 loyal users"
        icon: "star"
          
queries:
  total_users: "SELECT COUNT(*) FROM users"
  previous_total_users: "SELECT COUNT(*) FROM users WHERE created_at < '2023-06-01'"
  growth_rate: "SELECT (COUNT(*) - previous_total_users) / previous_total_users * 100 FROM users"
  previous_growth_rate: "SELECT (COUNT(*) - (SELECT COUNT(*) FROM users WHERE created_at < '2023-05-01')) / (SELECT COUNT(*) FROM users WHERE created_at < '2023-05-01') * 100 FROM users"
  active_users: "SELECT COUNT(*) FROM users WHERE last_login > NOW() - INTERVAL '30 days'"
  previous_active_users: "SELECT COUNT(*) FROM users WHERE last_login > NOW() - INTERVAL '60 days' AND last_login <= NOW() - INTERVAL '30 days'"
  users_by_age: "SELECT age, COUNT(*) as count FROM users GROUP BY age"
  population_by_year: "SELECT year, population FROM population_data ORDER BY year"
  first_5_last_items: "SELECT * FROM items ORDER BY created_at DESC LIMIT 5"
  top_10_loyal_users: "SELECT user_id, loyalty_score FROM users ORDER BY loyalty_score DESC LIMIT 10"

Honour the user's dark scheme preferences

I love the light/dark modes! Would it be possible to honour when the user has a dark mode set, and default to that?

(I'd be happy raising a PR for this if of interest)

Build for `musl` based Linux distributions

After #16, I've been looking to deploy the sql-studio binary alongside a static Go binary in an Alpine container, when I noticed that the binary does not run:

ERRO An error occured with sql-studio: fork/exec /usr/local/bin/sql-studio: no such file or directory

Would it be possible to build the binary so it can be used with musl, the libc that Alpine uses? (possibly via or in a tweak to

targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
)

I can see:

$ file sql-studio-x86_64-unknown-linux-gnu/sql-studio
sql-studio-x86_64-unknown-linux-gnu/sql-studio: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=c392fa9b23eb5a8eb5322f258406ec13c98bf9ca, for GNU/Linux 3.2.0, stripped

no such module: spellfix1

Opening Plex sqlite database:

./sqlite-studio /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db --address 0.0.0.0:3030
2024-06-17T07:55:25.304260Z  INFO sqlite_studio: found 82 tables in /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db
2024-06-17T07:55:25.304454Z  INFO Server::run{addr=0.0.0.0:3030}: warp::server: listening on http://0.0.0.0:3030
2024-06-17T07:55:35.726239Z ERROR sqlite_studio::handlers: error while getting database overview: Rusqlite("no such module: spellfix1")

Postgresql and local socket connection (especially the local port)

When talking to a local database the most convenient option is to use local socket. No need for opening IP ports or password management, user access is controlled by kernel. Reasonable defaults are used by standard PostgreSQL client implementation, so no URL, hostname, port, username or even database name needs to be provided (when using local connection, default port, current logged-in user name and the database named after the user name):

jajcus@jajco:~$ psql
psql (14.12 (Ubuntu 14.12-0ubuntu0.22.04.1))
Type "help" for help.

jajcus=# 

I would expect the same (or similar) experience by any PotgreSQL client, but this is not the case with sql-studio:

jajcus@jajco:~$ sql-studio postgres 
error: the following required arguments were not provided:
  <URL>

Usage: sql-studio postgres <URL>

For more information, try '--help'.
jajcus@jajco:~$ sql-studio postgres postgresql:///
Error: 
   0: invalid configuration: both host and hostaddr are missing
   1: both host and hostaddr are missing

Location:
   src/main.rs:982

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
jajcus@jajco:~$ sql-studio postgres postgresql:///jajcus
Error: 
   0: invalid configuration: both host and hostaddr are missing
   1: both host and hostaddr are missing

Location:
   src/main.rs:982

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Is it even possible to connect to the database via local socket? What is the expected URL format in this case? E.g. postgresql:///jajcus works for sqlx.

BTW, requiring postgres command before a postgresql: URL is also a weird CLI choice โ€“ the URL already implies the database type โ€“ that is the very idea of using 'URLs' for database access.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.