13
GrapesDatabase
ItsTato edited this page 2024-04-30 00:07:50 -06:00
Table of Contents
Data Structure
Grapes uses a simple data storing structure, which goes as follows:
file_loc/data_directory-- Base data directory
file_loc/data_directory/tables -- Tables directory
file_loc/data_directory/tables/definition.bin -- Definition file (consistent data)
file_loc/data_directory/tables/{table}.grape -- Table file
Class Methods
| Method | What is this? | Arguments | Returns |
|---|---|---|---|
| __init__ | Class initializer | str file_loc (directory where data is stored, pass __file__), str data_directory defaults to: /data |
|
| __generate_files | Generates files based on the dir_structure passed |
dict dir_structure |
|
| __update_definition | Reads the contents of the definition.bin file and updates internal self.__tables |
||
| __upgrade_definition | Writes the internal self.__tables into the definition.bin file |
||
| force_reload | Calls __generate_files and __update_definition |
||
| create_table | Creates a new table in the database | grapes.Table table |
|
| delete_table | Deletes a table in the database (will error if it does not exist) | str table_name |
|
| has_table | Returns True or False depending on if the table name provided exists in the database | str table_name |
bool exists? |
| insert_into | Insert values into a table | str table_name, tuple[any,...] values |
|
| get_all | Gets all data from a table | str table_name |
list[Union[tuple[any,...],None]] values |
| get_where | Gets the first occurrence of something in a table | str table_name, str column_name, any is_equal_to |
Union[tuple[any,...],None] occurrence |
| get_all_where | Gets all occurrences of something in a table | str table_name, str column_name, any is_equal_to |
list[Union[tuple[any,...],None]] occurrences |
The Grapes Database Wiki
Grapes is powered by its community!
Feel free to join our Discord server!
Home
Installing
Classes
Table
Column
GrapesDatabase
The Grapes Database Wiki
End of Page
Lost? Go back to the homepage!
Need help? Join our community server!