{"id":16730528,"url":"https://github.com/c42f/sqlrepl.jl","last_synced_at":"2026-01-02T12:53:17.444Z","repository":{"id":61799608,"uuid":"461091432","full_name":"c42f/SQLREPL.jl","owner":"c42f","description":"A Julia REPL mode for SQL","archived":false,"fork":false,"pushed_at":"2022-03-10T00:37:13.000Z","size":13,"stargazers_count":66,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T22:28:20.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c42f.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-19T05:01:50.000Z","updated_at":"2024-08-06T17:57:04.000Z","dependencies_parsed_at":"2022-10-21T11:30:43.899Z","dependency_job_id":null,"html_url":"https://github.com/c42f/SQLREPL.jl","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c42f%2FSQLREPL.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c42f%2FSQLREPL.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c42f%2FSQLREPL.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c42f%2FSQLREPL.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c42f","download_url":"https://codeload.github.com/c42f/SQLREPL.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243769986,"owners_count":20345217,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T23:33:49.729Z","updated_at":"2026-01-02T12:53:17.410Z","avatar_url":"https://github.com/c42f.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQLREPL.jl\n\nA Julia REPL mode for PostgreSQL powered by\n[ReplMaker.jl](https://github.com/MasonProtter/ReplMaker.jl),\n[LibPQ.jl](https://github.com/invenia/LibPQ.jl) and\n[SQLStrings.jl](https://github.com/JuliaComputing/SQLStrings.jl).\n\n## Tutorial\n\nInstall the package with Julia's Pkg mode:\n```\npkg\u003e add SQLREPL\n```\n\nTo connect the REPL mode, you'll need a connection string for your Postgres\ndatabase. You can then use:\n\n```julia\njulia\u003e using SQLREPL\njulia\u003e SQLREPL.connect(\"your_connection_string\")\nREPL mode SQL initialized. Press ) to enter and backspace to exit.\n\"Prompt(\\\"SQL\u003e \\\",...)\"\n```\n\nNow press `)` to enter the REPL mode. You can create tables and do some simple\ndata insertion and extraction with standard SQL syntax:\n\n```sql\nSQL\u003e create table foo (x text, y int);\n\nSQL\u003e insert into foo values ('hi', 1);\n\nSQL\u003e insert into foo values ('ho ho', 2);\n\nSQL\u003e select * from foo\n2×2 DataFrame\n Row │ x        y      \n     │ String?  Int32? \n─────┼─────────────────\n   1 │ hi            1\n   2 │ ho ho         2\n```\n\nThanks to SQLStrings.jl, you can also interpolate local Julia values into your\nexpression. Let's set `min_y` in the Julia `Main` module:\n\n```julia\njulia\u003e min_y = 2\n```\n\nAnd we can now use `$min_y` within our queries:\n\n```sql\nSQL\u003e select * from foo where y \u003e= $min_y\n1×2 DataFrame\n Row │ x        y      \n     │ String?  Int32? \n─────┼─────────────────\n   1 │ ho ho         2\n```\n\nFor more complex data manipulation, the REPL mode can be combined with\nprogrammatic access via the normal Julia REPL:\n\n```julia\njulia\u003e using LibPQ, SQLStrings\n\njulia\u003e conn = LibPQ.Connection(\"\");\n\njulia\u003e for y=1:10\n           msg = \"Hi $y\"\n           LibPQ.execute(conn, sql`insert into foo values ($msg, $y)`)\n       end\n```\n\nthence\n\n```sql\nSQL\u003e select * from foo\n12×2 DataFrame\n Row │ x        y      \n     │ String?  Int32? \n─────┼─────────────────\n   1 │ hi            1\n   2 │ ho ho         2\n   3 │ Hi 1          1\n   4 │ Hi 2          2\n   5 │ Hi 3          3\n   6 │ Hi 4          4\n   7 │ Hi 5          5\n   8 │ Hi 6          6\n   9 │ Hi 7          7\n  10 │ Hi 8          8\n  11 │ Hi 9          9\n  12 │ Hi 10        10\n```\n\n\n## How To\n\n### Editing multi-line statements\n\nTo edit multi-line SQL statements easily, surround your statement with brackets:\n\n```sql\nSQL\u003e (select * from foo\n         where y \u003e 5\n         and   y \u003c= 7)\n2×2 DataFrame\n Row │ x        y      \n     │ String?  Int32? \n─────┼─────────────────\n   1 │ Hi 6          6\n   2 │ Hi 7          7\n```\n\nAlternatively, to insert a line, the usual key binding `ALT+Enter` can always be used.\n\n### Accessing the result of the previous query\n\nThe resulting `DataFrame` is available in the `ans` variable back in the Julia\nREPL. Starting with\n\n```sql\nSQL\u003e (select * from foo\n         where y \u003e 5\n         and   y \u003c= 7);\n```\n\nwe then have\n\n```julia\njulia\u003e ans\n2×2 DataFrame\n Row │ x        y      \n     │ String?  Int32? \n─────┼─────────────────\n   1 │ Hi 6          6\n   2 │ Hi 7          7\n```\n\n### Inspecting table schema\n\nTo inspect table schema you can use the `psql`-like meta-command `\\d`:\n\n```sql\nSQL\u003e \\d foo\n2×5 DataFrame\n Row │ column_name  data_type  character_maximum_length  column_default  is_nullable \n     │ String?      String?    Union{Missing, Int32}     String?         String?     \n─────┼───────────────────────────────────────────────────────────────────────────────\n   1 │ x            text                        missing  missing         YES\n   2 │ y            integer                     missing  missing         YES\n```\n\nIn the future we might implement more of the\n[`psql` meta-commands](https://www.postgresql.org/docs/14/app-psql.html).\n\n## Development\n\n[![Build Status](https://github.com/c42f/SQLREPL.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/c42f/SQLREPL.jl/actions/workflows/CI.yml?query=branch%3Amain)\n\nThis package arose from [a discussion](https://discourse.julialang.org/t/easiest-and-most-complete-package-for-postgresql-right-now-feb-2022/75920) on Julia discourse.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc42f%2Fsqlrepl.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc42f%2Fsqlrepl.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc42f%2Fsqlrepl.jl/lists"}