@hazem-shaker/sqlbite
v1.0.5
Published
A simple DBMS engine CLI tool - Create tables, insert, select, update, delete with SQL-like syntax
Maintainers
Readme
SQLBite
A simple DBMS (Database Management System) engine CLI tool built with C++.
Installation
Global Installation (Recommended)
npm i -g @hazem-shaker/sqlbiteThis installs the package globally, making the sqlbite command available from anywhere in your terminal.
Local Installation
npm i @hazem-shaker/sqlbiteThis installs the package in your current project's node_modules folder.
Note: This package only supports Windows.
Usage
If installed globally:
sqlbiteIf installed locally:
npx sqlbiteWhy
npx? Local installs put the binary in./node_modules/.bin/which is not in your system PATH. Usingnpxtells npm to look in that folder and run the command. Withoutnpx, your terminal won't find thesqlbitecommand.
Available Commands
Create Table
CREATE TABLE tablename (col1 PRIMARY KEY, col2, col3)
CREATE TABLE tablename (col1, col2, col3)Insert Data
INSERT INTO tablename VALUES (val1, val2, val3)Select Data
SELECT * FROM tablename
SELECT col1, col2 FROM tablename
SELECT * FROM tablename WHERE col = value
SELECT col1, col2 FROM tablename WHERE col > valueUpdate Data
UPDATE tablename SET col = value WHERE conditionExample:
UPDATE users SET name = John WHERE id = 1
UPDATE products SET price = 99 WHERE price < 50Delete Data
DELETE * FROM tablename
DELETE FROM tablename WHERE conditionExample:
DELETE * FROM logs
DELETE FROM users WHERE id = 3
DELETE FROM products WHERE price > 100Show Tables
SHOW
TABLESLists all tables in the database with their primary key information.
Help
HELPDisplays the help screen with all available commands.
Exit
EXITExits the program. You can also press ESC key to exit.
WHERE Operators
| Operator | Description |
|----------|-------------|
| = | Equal to |
| != | Not equal to |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal |
| <= | Less than or equal |
Primary Key
Use PRIMARY KEY after a column name to enforce uniqueness:
CREATE TABLE students (id PRIMARY KEY, name, grade)Duplicate primary key values will be rejected.
Data Storage
Tables are stored as .txt files in a ./data/ directory, created automatically in your current working directory.
Example Session
DBMS> CREATE TABLE users (id PRIMARY KEY, name, email)
Table 'users' created successfully with 3 columns. Primary key: 'id'.
DBMS> INSERT INTO users VALUES (1, Hazem, [email protected])
1 row inserted into 'users'.
DBMS> INSERT INTO users VALUES (2, Ahmed, [email protected])
1 row inserted into 'users'.
DBMS> SELECT * FROM users
| id | name | email |
+----+-------+-----------------+
| 1 | Hazem | [email protected] |
| 2 | Ahmed | [email protected] |
Rows returned: 2
DBMS> UPDATE users SET name = Hazem_Updated WHERE id = 1
1 row(s) updated in 'users'.
DBMS> SELECT name FROM users WHERE id = 1
| name |
+---------------+
| Hazem_Updated |
Rows returned: 1
DBMS> SHOW
Tables in database:
- users (PK: id)
DBMS> DELETE FROM users WHERE id = 2
1 row(s) deleted from 'users'.
DBMS> EXIT
Goodbye!Author
Hazem Mohamed Shaker
License
MIT
