- SQL like syntax
- Works directly with CSV
- Supports all CRUD functionalities like INSERT, DELETE etc
- No type checking
- Only one query at a time
- Doesn't support data with spaces
If you are using this package from the GitHub repository
yarn start
npm start
If you are using this package from the npm repository
require('kaizer-db')
That's it! No fancy configuration or boiler code. It's as easy as that!!!
-
Creating or using a database
Use Database dbname;
Create Database dbname;
Both these commands create a new folder named
dbname
where the tables are stored ascsv
files. -
Show list of tables
Show Tables;
Shows list of available csv files in the current directory which is used as the database.
-
Creating a table
Create Table Warriors (Name,Attack,Defense,PowerLevel);
Creates a file named
Warriors.csv
in the current folderdbname
with the given headers. -
Inserting data in a table
Insert into Warriors (Name,Attack,Defense,PowerLevel) values (Goku,5000,7000,9001), (Vegeta,5000,7000,9000);
Appends 2 records to the file named
Warriors.csv
-
Getting records from a table
Select * from Warriors;
Select Name, PowerLevel from Warriors;
-
Getting records from a table using
WHERE
clauseSelect Name from Warriors Where PowerLevel > 9000;
-
Getting records from a table using multiple
WHERE
clausesSelect * from Warriors Where PowerLevel > 9000 and Name = Goku;
Select * from Warriors Where PowerLevel > 9000 or Name = Vegeta;
-
Updating a record using
WHERE
clauseUpdate Table Warriors set PowerLevel = 10000, Defense = 8000 Where Name = Goku;
-
Deleting a record using
WHERE
clauseDelete From Warriors Where PowerLevel < 10000;
The default ordering is ascending order (
asc
,Asc
,ASC
)
The descending order can be used as (desc
,Desc
,DESC
)Select * from test_data order by Defense;
Select * from test_data where Attack > 200 order by Defense desc;
Select Name, PowerLevel, Defense from test_data where Attack > 200 Order by Defense;
> Select Name, PowerLevel from test_data where Attack > 200 Order by Defense; Error: Order by field needs to be included in fetch list
The sorting column must be present in the list of columns that needs to be fetched.
- Fork the repository in your GitHub account.
- Make your changes.
- Submit a pull request.
- Code should well documented.