@petradb/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/bin/main.js +5786 -0
- package/bin/petradb +2 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @petradb/cli
|
|
2
|
+
|
|
3
|
+
PetraDB — a lightweight PostgreSQL-compatible SQL database engine. This package provides the interactive CLI (REPL) and batch execution tool.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @petradb/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Interactive REPL
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# In-memory database
|
|
17
|
+
petradb -m
|
|
18
|
+
|
|
19
|
+
# Persistent database (creates or opens)
|
|
20
|
+
petradb mydb.petra
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Batch execution
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Execute a SQL file
|
|
27
|
+
petradb -m -f schema.sql
|
|
28
|
+
|
|
29
|
+
# Execute inline SQL
|
|
30
|
+
petradb -m -e "CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT);"
|
|
31
|
+
|
|
32
|
+
# Multiple operations
|
|
33
|
+
petradb -m -f schema.sql -f seed.sql -e "SELECT * FROM users;"
|
|
34
|
+
|
|
35
|
+
# Read SQL from stdin
|
|
36
|
+
echo "SELECT 1 + 1;" | petradb -m --stdin
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Flags
|
|
40
|
+
|
|
41
|
+
| Flag | Short | Description |
|
|
42
|
+
|------|-------|-------------|
|
|
43
|
+
| `--memory` | `-m` | Use in-memory database |
|
|
44
|
+
| `--file <path>` | `-f` | Execute SQL file (repeatable) |
|
|
45
|
+
| `--execute <sql>` | `-e` | Execute SQL string (repeatable) |
|
|
46
|
+
| `--stdin` | | Read SQL from stdin |
|
|
47
|
+
| `--path <path>` | | Database file path |
|
|
48
|
+
|
|
49
|
+
## Meta-commands
|
|
50
|
+
|
|
51
|
+
Inside the interactive REPL:
|
|
52
|
+
|
|
53
|
+
| Command | Description |
|
|
54
|
+
|---------|-------------|
|
|
55
|
+
| `\dt` | List all tables |
|
|
56
|
+
| `\d <table>` | Describe a table's columns |
|
|
57
|
+
| `\i <file>` | Execute a SQL file |
|
|
58
|
+
| `\dump` | Dump the database schema |
|
|
59
|
+
| `\q` | Quit |
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
Full documentation at [petradb.dev](https://petradb.dev).
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
ISC
|