-
Notifications
You must be signed in to change notification settings - Fork 5
Database
This peripheral allows the user to use a SQL database. basic SQL, prepared requests and diverse helpers may be used.
A Database Disk must be inserted inide the databse to function. Every disk holds a separate database and keeps it when transfered to another Database peripheral.
This peripheral uses SQLite databases, and as such it uses the SQL language for requests and prepared requests.
The maximum size of a Database Disk can be set in the server config file.
If you want to learn more about it:
Note: The helpers are a WIP feature so they are not documented yet, even if they are present ingame.
To be crafted, the Database requires:
- 6 stone blocks
- 1 redstone
- 1 iron ingot
- 1 disk drive
To be crafted, the Database Disk requires:
- 1 redstone
- 3 iron ingots
- 1 disk
The wraped peripheral will be named database
This checks if Database Disk is inserted inside the Database
This gets the database id for this disk.
Throws an error if no disk is inserted.
This gets the database name or nil
if no name was set for this disk.
Throws an error if no disk is inserted.
This sets the database name
for this disk.
Throws an error if no disk is inserted.
This executes the provided sql
string on the database, and returns a result structure.
Throws an error if no disk is inserted or if there was a problem with the SQL.
Note: This uses the SQLite language
This prepares the provided sql
request for the database, and returns a prepared statement.
Note: This uses the SQLite language and returns a Prepared Statement
This structure is returned by every call to the database.
-
type: string
This is the type of the result. May be"update"
,"query"
, or"error"
-
data: number / table / string
the data associated with this response. I repesents the number of updated entries iftype = "update"
, the returned table iftype = "query"
, and a summary od the error iftype = "error"
.
This structure is returned by the prepareStatement
method.
The structure will be named statement
This sets the parameter at index
in the Prepared Statement to value
, and returns the Prepared Statement.
This removes the parameter at index
in the Prepared Statement, and returns the Prepared Statement.
This executes the Prepared Statement, and returns a Result structure.
Throws an error if no disk is inserted or if there was a problem with the SQL.
This event is fired when a Database Disk is inserted inside the Database. This returns:
-
side: string
The side the Database is attached to. -
uuid: string
The id of the Database Disk. -
name: string
The name of the Database Disk.
This event is fired when a Database Disk is removed from the Database. This returns:
-
side: string
The side the Database is attached to.