{"id":20367070,"url":"https://github.com/ericyoungberg/prql","last_synced_at":"2025-04-12T05:12:32.789Z","repository":{"id":81093684,"uuid":"111917294","full_name":"ericyoungberg/prql","owner":"ericyoungberg","description":"Pronounced prequel 🌌","archived":false,"fork":false,"pushed_at":"2019-04-26T19:17:48.000Z","size":137,"stargazers_count":4,"open_issues_count":18,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T00:41:29.409Z","etag":null,"topics":["api","database","service"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericyoungberg.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-24T12:42:01.000Z","updated_at":"2021-12-06T09:12:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddedf97e-76ee-4b92-9637-8cd0a054b476","html_url":"https://github.com/ericyoungberg/prql","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/ericyoungberg%2Fprql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericyoungberg%2Fprql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericyoungberg%2Fprql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericyoungberg%2Fprql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericyoungberg","download_url":"https://codeload.github.com/ericyoungberg/prql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519556,"owners_count":21117761,"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":["api","database","service"],"created_at":"2024-11-15T00:28:52.786Z","updated_at":"2025-04-12T05:12:32.774Z","avatar_url":"https://github.com/ericyoungberg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrQL: SQL over HTTP\n_Note: This project is still in development. It is __not safe__ for production environments._\n\n[![CircleCI](https://circleci.com/gh/PrQL/prql/tree/master.svg?style=svg)](https://circleci.com/gh/PrQL/prql/tree/master)\n\n\n#### What is PrQL?\n\nPrQL is an ultra-lightweight layer that you place between your serverless application and your SQL database(s). \nWhat it does is allow a frontend application to gain access to your data without having to build out a backend.\nSometimes our needs are very simple and there isn't any purpose to building, maintaining, and standing up a REST API\nto funnel data between the SQL database and the client. That's where PrQL steps in and allows you to securely query\nyour database from any client (given that client has a token). In addition to ease of access, it allows the client to\ndecide what data it will receive and how it will receive it since you pass along a plain SQL query.\n\n#### What about GraphQL and JSON API?\n\nYou could consider PrQL to be a loose competitor to those two methods, but PrQL has different intentions. Although they \nboth allow you to define relationships within the data, neither give as much precision as actual SQL. This is especially\nproblematic if you work in the realm of GIS. Certain databases/database extensions allow you perform  complex operations on \nthe dataset before handing the data over to your application. Implementing an array of custom, complex operations for your \napp will most likely break REST conventions once you are all done writing your API. Why attempt to adhere to an ill-fitted \nspecification when you know that, in your work domain, you will always be breaking that spec?\n\nGraphQL and JSON API are great in the proper domain, but: JSON API is fancy REST. GraphQL is too simple yet too complex at \nthe same time.\n\n#### What about PostgREST?\n\nPostgREST is brilliant, but again, it serves a different purpose than PrQL. In addition to different solution sets, PostgREST\nis specific to PostgreSQL while PrQL is database agnostic. As long as you have a SQL database, PrQL will have a driver to \nconnect to it. \n\n\n## Usage\n\n- Define database locations\n- Generate a token to authenticate against a defined database\n- Add token to request headers in your client\n- Query your service for data\n\n\n### Setting up a database\n\nFirst, you have to inform PrQL of your database's location. You save this information by giving that database a name.\n\n```sh\nsudo prql databases new \\\n            --name localpg \\\n            --driver postgres \\ # possible options are postgres and mysql (will add more post-alpha)\n            --port 5432\n```\n\nThen, to view the newly added database:\n```sh\nsudo prql databases list\n```\n\n\n### Generating an app token\n\nNow you can generate a token that maps to a user in a database that you have previously defined. That way you have a \nsecure way of allowing the client to let PrQL know which database server and user to execute queries on.\n\n```sh\nsudo prql tokens new \\\n         --host localpg \\\n         --database myapp \\\n         --user myapp_user\n```\n\nTo view the tokens you have created, you follow the same pattern as the command above:\n```sh\nsudo prql tokens list\n```\n\n### Query your database\n\nTo tell PrQL which credentials to use, we pass a token as a query parameter. \n\n```sh\nwget -nv -O- \"localhost:1999?token=f04e79dc8d1dd5453da438366c6162fb\u0026query=SELECT id, name FROM users WHERE login_attempts \u003e 3\"\n```\n\n\n## Setup\n\n### Building\n\nThere are currently a two different ways of implementing the PrQL alpha:\n\n#### Go\n\n##### Dependencies\n- [dep](https://github.com/golang/dep#installation)\n- [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck)\n\n```sh\nmkdir -p \"$GOPATH/src/github.com/prql\"\ncd \"$GOPATH/src/github.com/prql\"\ngit clone https://github.com/prql/prql \u0026\u0026 cd prql\nmake\n```\n\n#### Docker\n\n```sh\nmake with-docker ARCH=$YOUR_DISTRO\n```\nWhere `$YOUR_DISTRO` is one of the following: `darwin/amd64` `darwin/386` `freebsd/amd64` `freebsd/386` `linux/arm` `linux/arm64` `linux/amd64` `linux/386` `solaris/amd64`\n\nYou will find your binaries in the _build/_ folder with your distro name appended.\n\n### Installation\n\nOn *nix systems, run `sudo ./install.sh`. This is a temporary measure for the alpha release. It sets up the necessary\nsystem directories and files, installs binaries, and attempts to enable `prqld` as a systemd service.\n\nOn Windows systems, :shrugs: I haven't figured out what that needs yet. It's in alpha afterall.\n\n### Running\n\nIf systemd exists on your system, `reboot` or `sudo systemctl start prqld`.\n\nOtherwise, you will have to manage prqld on your own by executing `prqld \u0026`.\n\nTo check if prqld is up and running, you can \n```sh\nlsof -iTCP -sTCP:LISTEN | grep prqld\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericyoungberg%2Fprql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericyoungberg%2Fprql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericyoungberg%2Fprql/lists"}