• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    OCaml
  • License
    Other
  • Created almost 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Petrol's an OCaml SQL API made to go FAST.

Petrol

Petrol is a Free software library that provides a high-level OCaml API for interacting with SQL databases. The aim of this interface is to provide a type-safe API to allow developers to define their SQL tables and queries directly in OCaml, thereby avoiding the impedence mismatch and fragility that comes with having to directly write SQL code, as is typical in a normal Caqti-based project.

open Petrol
open Petrol.Sqlite3

(* define a new schema *)
let schema = StaticSchema.init ()

(* declare a table *)
let example_table, Expr.[name; age] =
    StaticSchema.declare_table schema ~name:"example"
    Schema.[
        field "name" ~ty:Type.text;
        field "age" ~ty:Type.int
    ]

Petrol's DSL allows you to express complex SQL queries as simple OCaml function compositions:

open Petrol.Sqlite3

(* create a query *)
let insert_person ~name:n ~age:a db =
    Query.insert ~table:example_table
        ~values:Expr.[
            name := s n;
            age := i a
         ]
    |> Request.make_zero
    |> Petrol.exec db

See the rest of the documentation at here.

More Repositories

1

emacs-viewer

A web frontend for your Org-files (100% faithful to GNU+Emacs!)
Common Lisp
117
star
2

ocamlot

An Activitypub server in OCaml!
OCaml
66
star
3

rhombus-in-the-rough

A 2D RPG implemented in the Rhombus Racket dialect
GLSL
51
star
4

gopcaml-mode

[MIRROR] Ultimate Ocaml Editing Mode
OCaml
21
star
5

guile-ocaml

GNU Guile Scheme bindings for OCaml
OCaml
16
star
6

simple-pleroma-comments

Free, open source web commenting system in a single script (no-analytics, privacy friendly)!
OCaml
16
star
7

WacomTabletTool

Unofficial GUI Tool for configuring Wacom Tablets on Unix/Linux systems.
Shell
9
star
8

SWIPL-OCaml

SWI-Prolog Bindings for OCaml: https://gopiandcode.github.io/SWIPL-OCaml/swipl/index.html
OCaml
6
star
9

LibreRef

LibreRef is a free as in freedom digital referencing tool for artists.
OCaml
5
star
10

rhombus-mode

Emacs Major mode for Rhombus (experimental)
Emacs Lisp
4
star
11

fun-ip

Making IPv4 fun again! Who need DNS servers?
OCaml
4
star
12

C-Projects

A repository for all the cool C projects I do
C
4
star
13

UWP-RedditSlideshow

A Reddit Slideshow for the Universal Windows Platform...
C#
4
star
14

deriving-such-that

Lean
4
star
15

gop-music

Music synced to typing baby!
Python
3
star
16

dependent-view

A rust library for weak dependent views.
Rust
3
star
17

plebbit-bg-changer

OCaml rewrite of a python-based background changer
OCaml
3
star
18

query-complexity-framework

Framework for empirically exploring query complexity questions
OCaml
3
star
19

othudd

OCaml Theorem driven development - Tests are for losers.
Coq
3
star
20

cleango

Bindings to libclingo for the lean4 prover and programming language!
C
3
star
21

.nyxt.d

.nyxt.d config file (placed under $HOME/.config/nyxt/
Common Lisp
2
star
22

CamelClone

Automatically push changes to selected repositories - 0% tested yet 100% correct.
Coq
2
star
23

clingo-lang

#lang clingo for Racket (WIP)
Racket
2
star
24

ocaml-pug

Pug(lite) parser & compiler in OCaml
OCaml
1
star
25

Goptables

The best timetabling system you never knew you needed.
Python
1
star
26

coq-projects

Haskell? More like not-prooved-well! Got-em!
Coq
1
star
27

hit-front-page-of-hacker-news

Documenting Gopcaml-mode hitting the front-page of hacker news!
1
star
28

rust-projects

Might as well dip my toes into rust as well.
Rust
1
star
29

cvgenerator

Simple, Formal, Elegant. CV Generator
Java
1
star
30

python-projects

Repo for all the small cool experiments I've done in Python.
Python
1
star
31

ProjectNote

Large projects? *Note* a problem!
JavaScript
1
star
32

Activitybot-robotics-Project

A repo for the RoboticsProject
C
1
star
33

html_gen

A simple HTML templating engine built using literate programming
TeX
1
star