Author: tuonux <tuonux0@gmail.com>
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.
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")
Keep in mind: The index of the rows starts form 1 and not 0
Instantiate the connection with your binary database
Example Usage:
mrRobotDb = BinDB.connect("mrRobot", "mypassword", ["users", "mails", "banks"], "/home/<user>")
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"})
Fetch all the rows of your table
Example Usage:
for user in mrRobotDb.fetch("users")
print(user.name)
end for
Fetch a row by the index
Example Usage:
userElliot = mrRobotDb.fetchOne("users", 1)
Fetch a row by a combination of key -> value
Example Usage:
userElliot = mrRobotDb.fetchBy("users", "name", "Elliot")
Update a row by the index
Example Usage:
mrRobotDb.update("users", 1, {"name": "Mr.", "surname": "Robot"})
Delete a row by the index
Example Usage:
mrRobotDb.delete("users", 5)
Read binary buffer ( used in rare case )
Example Usage:
mrRobotDb.read()
Update binary database buffer
Example Usage:
mrRobotDb.insert("users", {"name": "Elliot", "surname": "Alderson"})
mrRobotDb.write()
Clear and delete the database
Example Usage:
mrRobotDb.wipe()
Utility function that print your table with formatted columns
Example Usage:
mrRobotDb.printTable("users", {"name": "Name", "surname": "Surname"})
For your convenience you can chain the methods if you want
mrRobotDb.insert("users", {"name": "Terry", "surname": "Colby"}).write()
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:~$
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.
- 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
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.