Skip to content

tuonux/gh-bindb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BinDB Library

Author: tuonux <[email protected]>

BinDB it's a library for Grey Hack Game that allow you to create and manage a password-protected binary database inaccessible to third parties and without need parsers or something like that.

How to use it

At the top of everything to your code import libbindb.src with the "import_code" method.

import_code("/absolute/path/of/libbindb.src")

After that, create a connection with your db with the following example method:

myDb = BinDB.connect("dbname", "dbpassword", ["table1", "table2"], "/home/tuonux")

Availables methods

Keep in mind: The index of the rows starts form 1 and not 0

BinDB.connect(dbname, dbpassword, tablesArray, dbDirectory)

Instantiate the connection with your binary database

Example Usage:

mrRobotDb = BinDB.connect("mrRobot", "mypassword", ["users", "mails", "banks"], "/home/<user>")

BinDB.insert(table, data)

Push the new data in your table

Example Usage:

mrRobotDb.insert("users", {"name": "Elliot", "surname": "Alderson"})
mrRobotDb.insert("users", {"name": "Tyrell", "surname": "Wellick"})
mrRobotDb.insert("users", {"name": "Angela", "surname": "Moss"})
mrRobotDb.insert("users", {"name": "Joanna", "surname": "Olofsson"})
mrRobotDb.insert("users", {"name": "Gideon", "surname": "Goddard"})

BinDB.fetch(table)

Fetch all the rows of your table

Example Usage:

for user in mrRobotDb.fetch("users")
     print(user.name)
end for

BinDB.fetchOne(table, id)

Fetch a row by the index

Example Usage:

userElliot = mrRobotDb.fetchOne("users", 1)

BinDB.fetchBy(table, key, value)

Fetch a row by a combination of key -> value

Example Usage:

userElliot = mrRobotDb.fetchBy("users", "name", "Elliot")

BinDB.update(table, id, data)

Update a row by the index

Example Usage:

mrRobotDb.update("users", 1, {"name": "Mr.", "surname": "Robot"})

BinDB.delete(table, id)

Delete a row by the index

Example Usage:

mrRobotDb.delete("users", 5)

BinDB.read()

Read binary buffer ( used in rare case )

Example Usage:

mrRobotDb.read()

BinDB.write()

Update binary database buffer

Example Usage:

mrRobotDb.insert("users", {"name": "Elliot", "surname": "Alderson"})
mrRobotDb.write()

BinDB.wipe()

Clear and delete the database

Example Usage:

mrRobotDb.wipe()

BinDB.printTable(table, labels)

Utility function that print your table with formatted columns

Example Usage:

mrRobotDb.printTable("users", {"name": "Name", "surname": "Surname"})

Methods chain

For your convenience you can chain the methods if you want

mrRobotDb.insert("users", {"name": "Terry", "surname": "Colby"}).write()

What if another user attempt to launch the binary database?

If someone tries to launch your database executable, an information message will be shown

tuonux@PC:~$ /home/tuonux/mrRobot.db

This is a binary database generated by BinDB Library
Info: https://github.com/tuonux/gh-bindb

tuonux@PC:~$

If someone tries to launch your database executable by passing a parameter and the password is incorrect, an error message will be shown

tuonux@PC:~$ /home/tuonux/mrRobot.db pass
Permission denied
tuonux@PC:~$

Protect the source code of your program

As long as you have your data protected in a binary database you are safe, but don't forget that as with any interpreted language, the source code of the code where you include the BinDB library could be visible to other people and they could find out your password.

Upload only the binary of your program or make sure you have the right permissions set on your file where the source code for your program resides.

Next Goals:

  • JOIN method to join between two or more tables
  • LIKE method to search a value in a row
  • Terminal GUI to explore your database in your terminal and perform queries directly from it

License

MIT License

Copyright (c) 2023 tuonux

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Create and manage a binary database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published