Prerequisites
- An AppSheet plan that supports database connections.
- Access to a Google Cloud Platform account.
Nomenclature
The following list defines a few terms with a focus on how they are used in relation to AppSheet.
- Database Instance: The database instance is the structure that manages a collection of database files. An instance can hold several databases. In the tutorial below, you will generate a public IP address to connect with the database instance.
- Database: A database is a collection of data. A database generally holds several tables. In AppSheet, each database will appear as an individual data source.
- Schema: In this context, schema and database are referring to the same thing. It is a collection of data made up of several tables. Schema is the term used in MySQL Workbench. Database is the term used in Google Cloud and AppSheet.
- Table: A table holds the actual data. A table generally has several columns, each with a specific type of data (such as, Name, email address, phone number, and so on). Each row contains a unique record. When viewing a form in AppSheet, each field in the form corresponds to a column in the table and saving the form creates a new row.
In summary, a database instance can have multiple databases and a database can have multiple tables.
Create a Database Instance
- Open your Google Cloud account and click SQL in the left menu.
- Click Create Instance.
- Choose your database engine. This tutorial uses MySQL.
Fill in the instance information. - Choose an Instance ID. This is how your database will be identified in the Google Cloud account.
- Select a root password.
- Choose the region. AppSheet servers are located in
us-west
andeurope-west
. For best performance, select between these two regions based on where the majority of your users are located. - Click Show configuration options to expand the configuration options.
- Under Connectivity ensure Public IP is checked. By checking this box, Google Cloud will create an IP address that you can use to connect your AppSheet account to the database instance.
- Click Add network.
- Enter the IP addresses listed in Manage IP addresses and firewall information. This allows the AppSheet server to connect directly to your database. Google Cloud requires the IP addresses in CIDR notation. To write the IP address in CIDR notation, add
/32
to the end of each IP address. For example,20.189.130.98
becomes20.189.130.98/32
. - Select the machine type and storage. Select a machine type with enough memory to hold your largest table.
- Update additional settings as needed. Generally, the default values for the remaining settings are correct.
- Click to Create the database instance. This will take a few minutes to complete.
Create a user account for the database instance
- After the database instance is created, click on the instance id to open the details page.
- Click Users and Create user account.
- Create a user name and password for the account that will be used to connect with AppSheet.
Record the username and password. After creating the account, you can change the password, but you cannot retrieve the password.
Create a Database - Method 1: Using Google Cloud Console
- Click Databases and Create database.
- Enter a database name and click Erstellen Sie.
Create a Database - Method 2: Using database visualization tool
A data visualization tool is a common way to interact with the database. This tutorial uses MySQL Workbench to access and modify the database.
- To connect to the database with MySQL Workbench, you must add your workstation’s IP address to the firewall allow list. You can find this by searching “What’s my IP address” in your browser.
- Allow your IP address in Google Cloud by following the same steps used to allow the AppSheet IP addresses.
- Open MySQL Workbench and create a new MySQL connection.
- The hostname is the public IP address for your database.
- The username and password are from the user account you created above.
- Click Test the Connection then click Ok.
- Create a new schema.
Note: The term schema in MySQL Workbench and the term database in Google Cloud (see Method 1 above) refer to the same thing.
Connect AppSheet to the Database
- Go to the My Account > Sources tab.
- Click + New Data Source.
- Enter a name for the data source and click Cloud Database or On-premises Database.
The Add database connection information dialog displays. - Configure the database connection information.
- Type: Select MySQL.
- Server: Enter the MySQL database server hostname or IP address.
- Database: Enter the database name.
- Username: Enter the username of the database user.
- Password:Enter the password for the database user.
- Click Test to test the connection details.
- After a successful test, click Authorize Access to save the data source in your AppSheet account.
Connect apps to the database
The database and schema are now connected to your AppSheet account. From within an AppSheet app, the process to add tables from a database is the same as adding tables from a spreadsheet. See Add a table.
The database may appear in your AppSheet account as database-1. You can change the name for your database in AppSheet as follows:
- Navigate to My account > Sources.
- Click on the database you'd like to update.
- This opens a box where you can modify the name. Enter a new name (such as, AppSheet_Demo) and click Cloud Database.
- Fill in the same connection information and click Authorize Access. The database will now appear with the new name in AppSheet.
See also: Use data from MySQL