All Projects → Kamirus → Purescript Selda

Kamirus / Purescript Selda

Licence: mit
A type-safe, high-level SQL library for PureScript

Programming Languages

purescript
368 projects

Projects that are alternatives of or similar to Purescript Selda

Walkable
A Clojure(script) SQL library for building APIs: Datomic® (GraphQL-ish) pull syntax, data driven configuration, dynamic filtering with relations in mind
Stars: ✭ 384 (+433.33%)
Mutual labels:  sql, query, postgresql, sqlite3
Openrecord
Make ORMs great again!
Stars: ✭ 474 (+558.33%)
Mutual labels:  sql, postgresql, sqlite3
Loukoum
A simple SQL Query Builder
Stars: ✭ 305 (+323.61%)
Mutual labels:  sql, query, postgresql
Qb
The database toolkit for go
Stars: ✭ 524 (+627.78%)
Mutual labels:  sql, postgresql, sqlite3
Octosql
OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
Stars: ✭ 2,579 (+3481.94%)
Mutual labels:  sql, query, postgresql
Knex
A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.
Stars: ✭ 15,083 (+20848.61%)
Mutual labels:  sql, postgresql, sqlite3
Shmig
Database migration tool written in BASH.
Stars: ✭ 408 (+466.67%)
Mutual labels:  sql, postgresql, sqlite3
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+929.17%)
Mutual labels:  sql, postgresql, sqlite3
Pmacct
pmacct is a small set of multi-purpose passive network monitoring tools [NetFlow IPFIX sFlow libpcap BGP BMP RPKI IGP Streaming Telemetry].
Stars: ✭ 677 (+840.28%)
Mutual labels:  sql, postgresql, sqlite3
Lucid
AdonisJS official SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
Stars: ✭ 613 (+751.39%)
Mutual labels:  sql, postgresql, sqlite3
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (+134.72%)
Mutual labels:  sql, postgresql, sqlite3
Fluentpdo
A PHP SQL query builder using PDO
Stars: ✭ 783 (+987.5%)
Mutual labels:  sql, query, postgresql
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (+2763.89%)
Mutual labels:  sql, postgresql, sqlite3
Sqliterally
Lightweight SQL query builder
Stars: ✭ 231 (+220.83%)
Mutual labels:  sql, query, postgresql
Sworm
a write-only ORM for Node.js
Stars: ✭ 128 (+77.78%)
Mutual labels:  sql, postgresql, sqlite3
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+1659.72%)
Mutual labels:  sql, postgresql, sqlite3
Trdsql
CLI tool that can execute SQL queries on CSV, LTSV, JSON and TBLN. Can output to various formats.
Stars: ✭ 593 (+723.61%)
Mutual labels:  sql, postgresql, sqlite3
Usql
Universal command-line interface for SQL databases
Stars: ✭ 6,869 (+9440.28%)
Mutual labels:  sql, postgresql, sqlite3
Pangres
SQL upsert using pandas DataFrames for PostgreSQL, SQlite and MySQL with extra features
Stars: ✭ 68 (-5.56%)
Mutual labels:  sql, postgresql, sqlite3
Go Starter
An opinionated production-ready SQL-/Swagger-first RESTful JSON API written in Go, highly integrated with VSCode DevContainers by allaboutapps.
Stars: ✭ 37 (-48.61%)
Mutual labels:  sql, postgresql

purescript-selda

CI

About

purescript-selda is an SQL library (eDSL) which allows a user to write type-safe queries.

  • Generated SQL is guaranteed to be correct by the type system.
  • It supports arbitrarily nested queries with capabilities of filtering, joins and aggregation.
  • We used standard monadic abstraction which supports writing queries in a linear, natural style.
  • Our main target is PostgreSQL though in the upcoming release (already on master) we add SQLite3 support (with ability to support other db backends).

Example Query

To declare a type for a SQL table (already created in the db) we write the following table definition:

people ∷ Table (id ∷ Int, name ∷ String, age ∷ Maybe Int)
people = Table { name: "people" }

Once we've defined the tables, we can write queries, e.g.

selectFrom people \{ id, name, age } → do
  { balance } ← leftJoin bankAccounts \b → id .== b.personId
  restrict $ id .> lit 1
  pure { id, balance }

Generated SQL for the above query:

SELECT people_0.id AS id, bank_accounts_1.balance AS balance
FROM people people_0
LEFT JOIN bank_accounts bank_accounts_1 ON ((people_0.id = bank_accounts_1.personId))
WHERE ((people_0.id > 1))

For a more gentle introduction and more examples please refer to the Step-by-Step Guide.

More Help

If you have any questions please don't hesitate to ask.
I'll be happy to help and provide any guidance if necessary.
Open an issue or hit me up directly (either on slack, forum or directly via email).

Install

Install postgresql-client's dependencies

npm install pg decimal.js

Info

  • Introductory Guide: End-to-End example: how to setup, write queries, use aggregation, deal with type errors and execute queries and inserts.
  • Advanced Guide: Custom Types and Expressions (litPG, Any, EForeign, custom PG functions), more flexible table definitions (Source, db schemas, set-returning functions) - unsafe escape hatches
  • Test Suite: For information about features, examples, usage, etc. refer to the test suite: Test.Common, Test.PG, Test.SQLite3. To run the tests, docker-compose up -d helps to prepare postgres database.
  • Documentation: Pursuit docs
  • My thesis

Credits

Supported by Lambda Terms

Inspired by selda

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].