• Stars
    star
    133
  • Rank 270,495 (Top 6 %)
  • Language
    Zig
  • Created almost 2 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Writing a SQL database, take two: Zig and RocksDB

zigrocks: a basic SQL database in Zig, with storage via RocksDB

See Writing a SQL database, take two: Zig and RocksDB for a walkthrough!

Build:

$ git clone https://github.com/facebook/rocksdb
$ ( cd rocksdb && make shared_lib -j8 )
$ zig build

And run!

$ ./main --database data --script <(echo "CREATE TABLE y (year int, age int, name text)")
echo "CREATE TABLE y (year int, age int, name text)"
ok
$ ./main --database data --script <(echo "INSERT INTO y VALUES (2010, 38, 'Gary')")
echo "INSERT INTO y VALUES (2010, 38, 'Gary')"
ok
$ ./main --database data --script <(echo "INSERT INTO y VALUES (2021, 92, 'Teej')")
echo "INSERT INTO y VALUES (2021, 92, 'Teej')"
ok
$ ./main --database data --script <(echo "INSERT INTO y VALUES (1994, 18, 'Mel')")
echo "INSERT INTO y VALUES (1994, 18, 'Mel')"
ok

# Basic query
$ ./main --database data --script <(echo "SELECT name, age, year FROM y")
echo "SELECT name, age, year FROM y"
| name          |age            |year           |
+ ====          +===            +====           +
| Mel           |18             |1994           |
| Gary          |38             |2010           |
| Teej          |92             |2021           |

# With WHERE
$ ./main --database data --script <(echo "SELECT name, year, age FROM y WHERE age < 40")
echo "SELECT name, year, age FROM y WHERE age < 40"
| name          |year           |age            |
+ ====          +====           +===            +
| Mel           |1994           |18             |
| Gary          |2010           |38             |

# With operations
$ ./main --database data --script <(echo "SELECT 'Name: ' || name, year + 30, age FROM y WHERE age < 40")
echo "SELECT 'Name: ' || name, year + 30, age FROM y WHERE age < 40"
| unknown               |unknown                |age            |
+ =======               +=======                +===            +
| Name: Mel             |2024           |18             |
| Name: Gary            |2040           |38             |

References:

More Repositories

1

gosql

An early PostgreSQL implementation in Go
Go
676
star
2

dbcore

Generate applications powered by your database.
Go
501
star
3

jsc

A JavaScript compiler written in TypeScript targeting C++/V8
TypeScript
194
star
4

goraft

A basic Raft implementation in Go.
Go
193
star
5

lust

A parser, compiler, and virtual machine evaluator for a minimal subset of Lua; written from scratch in Rust.
Rust
186
star
6

raft-rs

Another minimal Raft implementation in Rust.
Rust
171
star
7

lisp-rosetta-stone

A lisp rosetta stone to demonstrate modern language features
JavaScript
171
star
8

owebl

OCaml, Meet Web.
OCaml
157
star
9

ponyo

Library and Toolkit for Standard ML
Standard ML
143
star
10

ulisp

A compiler for a lisp-like language targeting LLVM IR, x86 assembly
JavaScript
125
star
11

vhostm

Manage nginx virtual servers and hosts file entries
Python
105
star
12

x86e

A simple x86 emulator, debugger, and editor in JavaScript.
JavaScript
102
star
13

waterbugdb

Raft + Postgres parser + Postgres wire protocol + Boltdb + ? = Distributed PostgreSQL
Go
97
star
14

pj

A small, hand-written Python JSON library
Python
93
star
15

bsdscheme

A Scheme (R7RS) implementation written in D
D
58
star
16

tinyprograms

Tiny Programs: Rosetta code for implementations
Python
55
star
17

databases-intuition

Building an intuition for latency and throughput of basic operations across SQL databases.
Go
47
star
18

docdb

Basic document db from scratch in Go
Go
46
star
19

jsforth

A Forth REPL in Javascript.
JavaScript
43
star
20

pyc

A Python to C compiler
Python
40
star
21

gomvcc

Go
40
star
22

gomail

SMTP server from scratch in Go
Go
39
star
23

notes.eatonphil.com

HTML
39
star
24

raft-example

Minimal hashicorp/raft example
Go
32
star
25

deferlint

Linter for finding defer statements in Go loops
Go
32
star
26

referenceserver

Barebones UNIX socket servers
C
26
star
27

goi

What else would you do with go/parser
Go
26
star
28

io-playground

Building an intuition for different IO models (sync, io_uring, etc.) across different languages.
Zig
25
star
29

gosqlite

SQLite driver for the Go programming language
C
23
star
30

livescheme

Building a scheme live on Twitch in Golang
Go
20
star
31

pgext-101

Bare minimal Postgres extension
C
20
star
32

btree-rs

Rust
19
star
33

bootloaders

Bootloader exploration
Assembly
19
star
34

go-amd64-emulator

Userland linux/amd64emulator in Go
Go
19
star
35

one-pass-code-generation-in-v8

One-pass Code Generation in V8 (Archive)
18
star
36

pgtam

Experiments with Postgres Table Access Methods
C
18
star
37

cpp-json

A basic JSON library in modern C++
C++
16
star
38

linode_deploy_experimental

Deploy FreeBSD, OpenBSD, NetBSD, etc. to Linode unattended in minutes
Python
15
star
39

zig-metaprogramming-css-parser

Demoing the basics of metaprogramming in Zig by writing a very incomplete CSS parser.
Zig
14
star
40

jqgo

Variations on experimental Go clones of jq
Go
12
star
41

fastcgi-development-kit

See https://github.com/FastCGI-Archives/fcgi2 for a "maintained" mirror
Shell
12
star
42

pgexec

Messing with Postgres query execution and hook infrastructure.
C
12
star
43

io_uring-basics-writing-file

Zig
10
star
44

jvm-lisp-examples

Examples of Lisp on the JVM
Common Lisp
10
star
45

gozip

A simple zip implementation in Go
Go
8
star
46

pytemplate

Basic templating library written in Python
Python
8
star
47

slowjs

C
7
star
48

jsi

An interpreter built on the TypeScript Compiler API
TypeScript
7
star
49

eatonphil.com

eatonphil.com
HTML
6
star
50

uweb

A web framework for teaching web server basics.
JavaScript
6
star
51

exploring-plpgsql

PLpgSQL
6
star
52

benchmarking-interpreters

Benchmarking an ast interpreter, bytecode vm, and compiler
Go
5
star
53

riscve

A RISC-V user-mode emulator for RV64I
Go
5
star
54

learnit

A script for creating google calendar events from a dictionary
Go
5
star
55

accord-protocol

CEP-15: Fast General Purpose Transactions
5
star
56

zig-libtcc

Zig
4
star
57

pine

Pine is a web framework for Chicken Scheme using FastCGI
Scheme
4
star
58

pgkv

pgkv: A key-value API for learning Postgres C
C
4
star
59

tnet

A minimal TCP/IP stack via Linux TAP device
C
3
star
60

graphics-playground

C#
3
star
61

linode-haskell

Haskell wrapper for the Linode v4 API
Haskell
3
star
62

gostorage

Exploring database storage
Go
2
star
63

python3-linode_api3

A Linode APIv3 client for Python3
Python
2
star
64

mod_ocaml

Apache module to allow embedded OCAML.
C
2
star
65

jx

Apparently, this project prefers to keep an air of mystery about it.
Rust
2
star
66

scripts

Personal scripts for system administration, common stuff
Shell
1
star
67

sml-mode

sml-mode for emacs
Emacs Lisp
1
star
68

govsr

Can I implement Viewstamped Replication?
Go
1
star
69

iouring-playground

Zig
1
star
70

imaging

Image effects in Javascript
JavaScript
1
star
71

games

JavaScript
1
star
72

nycsystems.xyz

https://nycsystems.xyz
HTML
1
star
73

badio

Zig
1
star