This guide will help you get started with LangDB in just a few minutes.
- Rust and Cargo installed (1.70+ recommended)
- Basic knowledge of SQL
- Clone the repository:
git clone https://github.com/Okemwag/langdb.git
cd langdb- Build the project:
cargo build --release- Run LangDB:
cargo run --releaseOnce LangDB starts, you'll see the interactive prompt:
langdb>
CREATE TABLE users (id INTEGER, name TEXT, email TEXT);INSERT INTO users VALUES (1, 'Alice', 'alice@example.com');
INSERT INTO users VALUES (2, 'Bob', 'bob@example.com'), (3, 'Charlie', 'charlie@example.com');SELECT * FROM users;Output:
| id | name | email |
+----+-----------+---------------------+
| 1 | 'Alice' | 'alice@example.com' |
| 2 | 'Bob' | 'bob@example.com' |
| 3 | 'Charlie' | 'charlie@example.com' |
3 row(s) returned
SELECT name, email FROM users WHERE id > 1;Output:
| name | email |
+-----------+---------------------+
| 'Bob' | 'bob@example.com' |
| 'Charlie' | 'charlie@example.com' |
2 row(s) returned
LangDB supports several special commands:
.help- Display help information.tables- List all tables in the database.exitor.quit- Exit LangDB
Example:
langdb> .tables
Tables:
users
products
orders
CREATE TABLE products (
id INTEGER,
name TEXT,
price INTEGER,
description TEXT NULL
);INSERT INTO products (id, name, price) VALUES (1, 'Laptop', 1200);Supported operators: =, <>, !=, >, <, >=, <=
SELECT * FROM products WHERE price >= 1000;
SELECT name FROM products WHERE id = 1;
SELECT * FROM products WHERE name <> 'Laptop';INSERT INTO products VALUES (2, 'Phone', 800, NULL);
SELECT * FROM products WHERE description = NULL;You can write SQL statements across multiple lines. LangDB will wait for the semicolon:
langdb> SELECT id, name, price
....... FROM products
....... WHERE price > 500;Here's a complete example session:
-- Create a table
CREATE TABLE books (id INTEGER, title TEXT, author TEXT, year INTEGER);
-- Insert some books
INSERT INTO books VALUES
(1, 'The Rust Programming Language', 'Steve Klabnik', 2018),
(2, 'Programming Rust', 'Jim Blandy', 2017),
(3, 'Rust in Action', 'Tim McNamara', 2021);
-- Query all books
SELECT * FROM books;
-- Find recent books
SELECT title, year FROM books WHERE year >= 2020;
-- List all tables
.tables
-- Exit
.exitYou can pipe SQL commands from a file:
./target/release/langdb < demo.sqlOr using cargo:
cargo run --release < demo.sqlRun the provided test script:
./test_run.shThis will build the project and run a quick test to verify everything is working.
- Read the full README.md for detailed documentation
- Check out demo.sql for more examples
- Review the CHANGELOG.md for version history
- Explore the source code to understand the implementation
If you encounter build errors, make sure you have:
- Rust 1.70 or later installed
- Updated cargo:
rustup update
- Make sure SQL statements end with a semicolon (
;) - Check that table names and column names are spelled correctly
- Verify that data types match the schema
- Use
.helpcommand in the REPL - Check the README.md for detailed documentation
- Review error messages carefully - they usually indicate what went wrong
LangDB is an educational project. Experiment with it, break it, and learn from it. Happy querying!