Database action
- Enviroment variables
- test mode: store data in the disk file in the server, not in the database if the test mode is on
- username: database username
- password: database password
- Create connection: check the test mode and choose the correct database. If it is test mode, use SQLite. Otherwise, use MySQL
- <details><summary>Build condition query: simple condition query with some simple join</summary>
- Input
- conditions: array with key and value to be the one to be used as conditions
- connector: word to connect all the condition query together. Default to be "AND"
- Output: string to show the condition which is all joint
- Example:
- Input
```
{
"building_id": 1,
"name": "test"
}
```
- Output
```
WHERE `building_id` = '1' AND `name`='test'
```
</details>
- Build insert, update and delete query
</details>
-
Bulk insert
- Depending on the table, need to convert the Excel columns to the right column from database.
- For the column which users can choose by name such as Building, need to convert that building name to the corresponding building ID.
- For date column, need to make sure to convert the format Date Month Year to Year Month Date so it can go to the database table
- For columns which are not in the column list, ignore them.
- Convert all the columns to the insert query
- Execute all the queries as a transaction and roll back if there is any errors.
- Create Excel template