npm package: @hazem-shaker/sqlbite
Description: A simple DBMS engine CLI tool - Create tables, insert, select, update, delete with SQL-like syntax
Author: Hazem Mohamed Shaker
Latest version: 1.0.5

# SQLBite

A simple DBMS (Database Management System) engine CLI tool built with C++.

## Installation

### Global Installation (Recommended)

```bash
npm i -g @hazem-shaker/sqlbite
```

This installs the package globally, making the `sqlbite` command available from anywhere in your terminal.

### Local Installation

```bash
npm i @hazem-shaker/sqlbite
```

This installs the package in your current project's `node_modules` folder.

> **Note:** This package only supports Windows.

## Usage

### If installed globally:

```bash
sqlbite
```

### If installed locally:

```bash
npx sqlbite
```

> **Why `npx`?** Local installs put the binary in `./node_modules/.bin/` which is not in your system PATH. Using `npx` tells npm to look in that folder and run the command. Without `npx`, your terminal won't find the `sqlbite` command.

## Available Commands

### Create Table
```sql
CREATE TABLE tablename (col1 PRIMARY KEY, col2, col3)
CREATE TABLE tablename (col1, col2, col3)
```

### Insert Data
```sql
INSERT INTO tablename VALUES (val1, val2, val3)
```

### Select Data
```sql
SELECT * FROM tablename
SELECT col1, col2 FROM tablename
SELECT * FROM tablename WHERE col = value
SELECT col1, col2 FROM tablename WHERE col > value
```

### Update Data
```sql
UPDATE tablename SET col = value WHERE condition
```
Example:
```sql
UPDATE users SET name = John WHERE id = 1
UPDATE products SET price = 99 WHERE price < 50
```

### Delete Data
```sql
DELETE * FROM tablename
DELETE FROM tablename WHERE condition
```
Example:
```sql
DELETE * FROM logs
DELETE FROM users WHERE id = 3
DELETE FROM products WHERE price > 100
```

### Show Tables
```sql
SHOW
TABLES
```
Lists all tables in the database with their primary key information.

### Help
```sql
HELP
```
Displays the help screen with all available commands.

### Exit
```sql
EXIT
```
Exits 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:

```sql
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, hazem@email.com)
1 row inserted into 'users'.

DBMS> INSERT INTO users VALUES (2, Ahmed, ahmed@email.com)
1 row inserted into 'users'.

DBMS> SELECT * FROM users
| id | name  | email           |
+----+-------+-----------------+
| 1  | Hazem | hazem@email.com |
| 2  | Ahmed | ahmed@email.com |

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