-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #740 from macolso/sql-in-cloud
Sqlite in cloud documentation
- Loading branch information
Showing
5 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
title = "NoOps SQLite Database" | ||
template = "cloud_main" | ||
date = "2023-07-26T16:00:00Z" | ||
enable_shortcodes = false | ||
[extra] | ||
url = "https://github.com/fermyon/developer/blob/main/content/cloud/noops-sql-db.md" | ||
|
||
--- | ||
|
||
- [Accessing Private Beta](#accessing-private-beta) | ||
- [Quotas And Service Limitations For the Database in Fermyon Cloud](#quotas-and-service-limitations-for-the-database-in-fermyon-cloud) | ||
- [How To:](#how-to) | ||
- [Prepare a Database](#prepare-a-database) | ||
- [Manage the Database Lifecycle](#manage-the-database-lifecycle) | ||
- [FAQ](#faq) | ||
- [Next Steps](#next-steps) | ||
|
||
With NoOps SQL Database using SQLite support in Fermyon Cloud, you can persist relational data generated by your Spin application in between application invocations without having to worry about database management. Fermyon Cloud will provision and manage the database on your behalf, no operations (NoOps) required. Fermyon Cloud will do the heavy lifting for you. To learn more about the Spin SQLite SDK, please visit the [API guide](../spin/sqlite-api-guide.md). | ||
|
||
<iframe width="854" height="480" src="https://www.youtube.com/embed/buwr66oRPbU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> | ||
|
||
## Accessing Private Beta | ||
|
||
The database in Fermyon Cloud is currently in private beta. To request access to the private beta, please fill out this short [sign-up form](https://fibsu0jcu2g.typeform.com/to/Brv12FI0#hubspot_utk=xxxxx&hubspot_page_name=xxxxx&hubspot_page_url=xxxxx). | ||
|
||
> Please note that the private beta is limited in space and all requests cannot be guaranteed. | ||
Once you have access to the private beta, please ensure you have [Spin CLI](./cli-reference.md) v1.4 or greater, and [`cloud` plugin](https://github.com/fermyon/cloud-plugin) vX.Y or greater installed. | ||
|
||
## Quotas And Service Limitations For the Database in Fermyon Cloud | ||
|
||
*Quotas* | ||
* You can have a maximum of 1 NoOps SQL Database in your Cloud account | ||
* Your NoOps SQL Database can hold up 1 GB of data | ||
|
||
*Service Limitations* | ||
* The `--sqlite` flag not supported on `spin cloud deploy` | ||
* Fermyon **Cloud** only supports databases named "default" at this time | ||
|
||
## How To: | ||
|
||
### Prepare a Database | ||
|
||
You can use the `spin cloud sqlite execute` command to check if a table needs to be created, and if so create one: | ||
|
||
```bash | ||
$ spin cloud sqlite execute inspirational-pig "CREATE TABLE IF NOT EXISTS todos (id INTEGER PRIMARY KEY AUTOINCREMENT,description TEXT NOT NULL,due_date DATE,starred BOOLEAN DEFAULT 0,is_completed BOOLEAN DEFAULT 0)" | ||
``` | ||
|
||
>> If you need to look up the name of your database, use the `spin cloud sqlite list` command | ||
### Manage the Database Lifecycle | ||
|
||
A database is created when you deploy a Spin application that references a "default" SQLite database in its component manifest. Multiple components in the same Spin application can be given access to the default database like so: | ||
|
||
```toml | ||
# c1 does not have access to the default database | ||
[component] | ||
name = "c1" | ||
|
||
# c2 can use the default database | ||
[component] | ||
name = "c2" | ||
sqlite_databases = ["default"] | ||
|
||
# c3 can use default database as well | ||
[component] | ||
name = "c3" | ||
sqlite_databases = ["default"] | ||
``` | ||
|
||
The database will be created when the Spin application is deployed. The data persists Spin application invocations and updates. | ||
|
||
```bash | ||
$ spin cloud deploy | ||
Deploying app .. | ||
Creating database inspirational-pig (default) for app "quickstart" | ||
``` | ||
|
||
You can check to see your database by using the `spin cloud sqlite` command: | ||
|
||
>> Fermyon Cloud will automatically generate a random name for your database. | ||
```bash | ||
$ spin cloud sqlite list | ||
inspirational-pig (default) | ||
``` | ||
|
||
Lastly, (warning; using the `delete` subcommand is **permanent**) you can delete your default database with the following command: | ||
|
||
```bash | ||
$ spin cloud sqlite delete inspirational-pig | ||
The action is irreversible. | ||
Please type "strong-boson" for confirmation: strong-boson | ||
Deleting database ... | ||
Database "strong-boson" deleted | ||
``` | ||
|
||
> In the Private Beta, the database is inaccessible once the application has been deleted. However, we separate out the the database deletion step because we anticipate the database being accessible after deletion in a future beta. We enforce database deletion to prevent unintentional data sharing between Spin applications. | ||
## FAQ | ||
|
||
- **Can I export data from my database?** | ||
At this time, Fermyon Cloud does not have a data export feature. We'd love to hear your thoughts on what an ideal experience would look like at [github.com/fermyon/feedback](https://github.com/fermyon/feedback) | ||
|
||
- **If I upgrade my Spin application, can I still access the same instance of my database?** | ||
Yes, as long as you haven't deleted your database, the instance will be running and stateful. | ||
|
||
- **If I delete and redeploy my Spin application, can I still access the same instance of my database?** | ||
No, at this time you cannot access the database. You will need to delete the instance and provision a new one. | ||
|
||
## Next Steps | ||
|
||
* For support or feature feedback, please join our [Discord channel #no-ops-db-beta](https://discord.gg/XxkZvsya). This is where you can provide feedback and ask for assistance from the Fermyon Cloud team on all things NoOps SQL Database. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters