NoOps SQL Database
- Accessing Private Beta
- Quotas And Service Limitations For the Database in Fermyon Cloud
- Creating a New Spin Application
- Grant SQLite Permission
- Managing Your Local Spin Database Schema
- Tables and Data in Fermyon Cloud
- Deleting the Cloud Database
- FAQ
- 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 worrying about database management. Fermyon Cloud will provision and manage the database on your behalf:, no operations (NoOps) are required. Fermyon Cloud will do the heavy lifting for you. To learn more about the Spin SQLite SDK, please visit the API guide.
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.
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 v1.4 or greater, and cloud
plugin v0.1.2 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
-
To run a SQL statement (for migration and schema creation), use the
spin cloud sqlite list
andspin cloud sqlite execute
commands. The equivalent ofspin up --sqlite
forspin deploy
does currently not exist in Cloud. See this section for more info. -
Fermyon Cloud only supports databases named “default” at this time.
Creating a New Spin Application
If you already have a Spin application, you can skip this step. If you do not have a Spin application locally you will need to create one.
Grant SQLite Permission
To tell Spin that we want to use SQLite storage, we only need to grant SQLite permission to a component in the application’s manifest (the spin.toml
file). For example:
[component]
sqlite_databases = ["default"]
The new database file (sqlite_db.db
) is created in your application’s .spin
folder when you run this Spin application. The database persists across Spin application invocations and updates. The database is empty and can optionally have tables and data added using the following step.
Managing Your Local Spin Database Schema
See preparing an SQLite database for more information on using the spin up
subcommand’s --sqlite
option to create and populate tables locally. No Cloud database is created or changed as a result of using this this optional spin up --sqlite
example. Populating this local database can be useful for testing (the relationship between your application’s logic and your schema) before deploying your application to Fermyon Cloud.
Tables and Data in Fermyon Cloud
When you first spin cloud deploy
your application (with the sqlite_databases
configuration, as shown above), Fermyon Cloud will create a new database for your Cloud application.
The new database is initially empty, so you will need to create tables (and potentially initial data) before it is useful. To do this:
- Find the name of your Cloud database. To do this, run the following command:
$ spin cloud sqlite list
Databases (1)
inspirational-pig (default)
- Run
spin cloud sqlite execute
, passing the name of the database and the SQL statement(s) needed to create your Cloud database’s tables and initial data.
See the SQLite documentation for information about the SQLite dialect of SQL.
$ 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)"
Note: The Cloud database is completely unrelated to the local database, and must be prepared separately.
Deleting the Cloud Database
Warning: using the delete
subcommand is permanent.
You can delete your default database with the following command:
$ spin cloud sqlite delete inspirational-pig
The action is irreversible.
Please type "inspirational-pig" for confirmation: inspirational-pig
Deleting database ...
Database "inspirational-pig" deleted
In the Private Beta, we do not have support for sharing database between apps. However, we still separate out the database deletion from app deletion because we anticipate the ability to use databases from multiple apps in the future.
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
-
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. This is where you can provide feedback and ask for assistance from the Fermyon Cloud team on all things NoOps SQL Database.