Execute SQL now and get the results later.

Related tags

Database pg_later
Overview

pg_later

Execute SQL now and get the results later.

A postgres extension to execute queries asynchronously.

Installation

Add pg_later to shared_preload_libraries in postgresql.conf:

shared_preload_libraries = 'pg_later'

Clone the repository, build and run the extension with pgrx:

cargo pgrx run pg15

Initialize the extension's backend:

CREATE EXTENSION pg_later CASCADE;

SELECT pglater.init();

Execute a SQL query now:

select pglater.exec(
  'select * from pg_available_extensions order by name limit 2'
) as job_id;

 job_id 
--------
     1
(1 row)

Come back at some later time, and retrieve the results by providing the job id:

select pglater.fetch_results(1);

 pg_later_results                                                                                                                                                                                       
--------------------
{
  "query": "select * from pg_available_extensions order by name limit 2",
  "job_id": 1,
  "result": [
    {
      "name": "adminpack",
      "comment": "administrative functions for PostgreSQL",
      "default_version": "2.1",
      "installed_version": null
    },
    {
      "name": "amcheck",
      "comment": "functions for verifying relation integrity",
      "default_version": "1.3",
      "installed_version": null
    }
  ],
  "status": "success"
}
You might also like...
ReadySet is a lightweight SQL caching engine written in Rust that helps developers enhance the performance and scalability of existing applications.
ReadySet is a lightweight SQL caching engine written in Rust that helps developers enhance the performance and scalability of existing applications.

ReadySet is a SQL caching engine designed to help developers enhance the performance and scalability of their existing database-backed applications. W

SQL database to read and write
SQL database to read and write "discord"

GlueSQL Discord Storage After discussing how CI testing will be managed, we plan to move it upstream. Precautions for use discord ToS https://discord.

TDS 7.2+ (mssql / Microsoft SQL Server) async driver for rust

Tiberius A native Microsoft SQL Server (TDS) client for Rust. Supported SQL Server versions Version Support level Notes 2019 Tested on CI 2017 Tested

GlueSQL is a SQL database library written in Rust

GlueSQL is a SQL database library written in Rust. It provides a parser (sqlparser-rs), execution layer, and optional storage (sled) packaged into a single library.

An object-relational in-memory cache, supports queries with an SQL-like query language.

qlcache An object-relational in-memory cache, supports queries with an SQL-like query language. Warning This is a rather low-level library, and only p

Run SQL queries on CSV files

zsql run SQL queries on csv files A terminal utility to easily run SQL queries on CSV files. zsql is shipped as a small single binary powered by rust

Running SQL-like queries on files.

filesql Running SQL-like queries on files. Features Supported: REPL Basic SQL expressions. INSERT clause. (which inserts data into another file) WHERE

Tool to automate the visualisation of UML dependencies from a SQL file
Tool to automate the visualisation of UML dependencies from a SQL file

Doteur A simple tool to draw your mysql relations from exports. Help us If you use the tool, and like it, don't forget to add a star to the project on

Fully typed SQL query builder for Rust [deprecated]

What is Deuterium? Deuterium is a fancy SQL builder for Rust. It's designed to provide a DSL to easily build SQL queries in safe and typed way. Like R

Comments
  • [feature] - configure bgw db via GUC

    [feature] - configure bgw db via GUC

    the database that the background worker reads from is configured via an environment variable, and defaults to 'postgres'. Change this to read from a GUC - see pgrx test for an example.

    enhancement 
    opened by ChuckHend 0
  • [feature] - concurrent query excecutors

    [feature] - concurrent query excecutors

    The single background worker process currently polls on an interval. This is unlikely to scale when the number of queries in the queue grows. Build a feature to configure the number of concurrent worker processes, or implement some sort of concurrency in the background worker. Note, the background worker itself might be tricky to implement as a Rust async function, but we aren't using the SPI so maybe there is a work around.

    enhancement 
    opened by ChuckHend 0
  • [feature] - get job status

    [feature] - get job status

    Allow user to check the status of query, by job id, that has already been submitted. For example,

    SELECT pglater.get_status(10)
    

    This should return the entire job metadata (enqueued at time, query text ,etc.) and whether it is currently being processed, completed, or still in the queue.

    enhancement 
    opened by ChuckHend 0
  • [feature] - cancel a query by job id

    [feature] - cancel a query by job id

    When a query is submitted, user receives a job id in return. Implement a feature that allows the user to submit the job id and cancel the job before it finishes. This should be both removing it from the queue and canceling the job if it is in-flight. e.g.

    -- cancel job id 10
    SELECT pglater.cancel_job(10)
    
    enhancement 
    opened by ChuckHend 0
Owner
Tembo
Tembo
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.

SQLx ?? The Rust SQL Toolkit Install | Usage | Docs Built with ❤️ by The LaunchBadge team SQLx is an async, pure Rust† SQL crate featuring compile-tim

launchbadge 7.6k Dec 31, 2022
A Rust SQL query builder with a pleasant fluent API closely imitating actual SQL

Scooby An SQL query builder with a pleasant fluent API closely imitating actual SQL. Meant to comfortably build dynamic queries with a little bit of s

Aleksei Voronov 100 Nov 11, 2022
Gh-sql - Query GitHub Projects (beta) with SQL

gh-sql: Query GitHub Projects (beta) with SQL Installation gh extension install KOBA789/gh-sql Features SELECT items DELETE items UPDATE item fields

Hidekazu Kobayashi 108 Dec 7, 2022
SQL validator tool for BigQuery standard SQL.

bqvalid What bqvalid does bqvalid is the SQL validator tool for BigQuery standard SQL. bqvalid fails with error message if there's the expression that

null 10 Dec 25, 2022
rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

rust_arango enables you to connect with ArangoDB server, access to database, execute AQL query, manage ArangoDB in an easy and intuitive way, both async and plain synchronous code with any HTTP ecosystem you love.

Foretag 3 Mar 24, 2022
ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-text search.

ReefDB ReefDB is a minimalistic, in-memory and on-disk database management system written in Rust, implementing basic SQL query capabilities and full-

Sacha Arbonel 75 Jun 12, 2023
Query LDAP and AD with SQL

SQLDAP Ever wanted to query AD or LDAP with SQL like queries ? I'm going to answer this question myself: yes ! Why ? Because I never could remember al

null 9 Nov 15, 2022
FeOphant - A SQL database server written in Rust and inspired by PostreSQL.

A PostgreSQL inspired SQL database written in Rust.

Christopher Hotchkiss 27 Dec 7, 2022
Rust library to parse, deparse and normalize SQL queries using the PostgreSQL query parser

This Rust library uses the actual PostgreSQL server source to parse SQL queries and return the internal PostgreSQL parse tree.

pganalyze 37 Dec 18, 2022
PRQL is a modern language for transforming data — a simpler and more powerful SQL

PRQL Pipelined Relational Query Language, pronounced "Prequel". PRQL is a modern language for transforming data — a simpler and more powerful SQL. Lik

PRQL 6.5k Jan 5, 2023