How do I connect to a FeatureBase cloud database with fbsql?
Connect to a FeatureBase cloud database when you startup fbsql.
Before you begin
- Create a database
- Learn about “docopt” notation standards used in this guide
- Learn about fbsql
- Create a FeatureBase Cloud database
Enter
fbsql --help
at the CLI to list available commands.\q
quits the fbsql interface.
Syntax
(<cli-flag-prefix>)
(
--host="<hostname>" \ -(p|-port)=<port> \
(
--api-key="<cloud-public-key>" |
(--email="user-email" \ --password="<user-pass>") |
--config=<filename.toml>
)
)
[
-[d|-dbname]="<cloud-database-name>" |
-[f|-file] <filename> |
<load-from-datasource>
]
CLI flag Prefix
Commands can be executed from the CLI or fbsql interface using the appropriate prefix:
Interface | Prefix | Example |
---|---|---|
CLI | fbsql | fbsql --config=cloud-user-connect.toml |
fbsql | \! | \! --config=cloud-user-connect.toml |
Database connection flags
Argument | Description | Default | Additional information |
---|---|---|---|
--host="<hostname>" | Specifies remote host name IP address or URL of the machine on which FeatureBase is running | localhost | |
-p --port | Specify TCP port on which FeatureBase is listening for connections. | ||
--api-key="<public-key>" | API public key flag that can be used to authenticate with your cloud organization | Obtain Cloud API key | |
--email="user@example.com" \ --password="a1b2c3d4e5f6" | User email and password credentials for FeatureBase application | Create Cloud users | |
--config=filename.toml | Designate a TOML file containing connection details | TOML connection file |
Optional arguments
Connect to available database
The following commands are equivalent:
fbsql -[d|-dbname] <cloud-database-name>
and
\[c|connect]="<cloud-database-name>"
Argument | Description | Additional information |
---|---|---|
-[d|-dbname]="<cloud-database-name>" | Connect to available Cloud database | Create a Cloud database |
Load SQL from a source file
Argument | Description | Additional information |
---|---|---|
-[f|-file] <filename> | Run content from file which can include valid meta-commands and SQL queries | equivalent to [i|include <filename>] meta-command |
Load data from data source
Additional information
Obtain Cloud API key
There are several ways to create an API key for your FeatureBase Cloud account:
Connection file
You can setup a file containing connection details in the */fbsql/featurebase
directory or in an accessible file path.
Connections files have a .toml
extension and contain:
- a valid combination of arguments and values in form
argument = "value"
, - on individual lines,
- with leading
--
and trailing\
omitted.
fbsql status
fbsql displays status information at startup:
Status | Description | Additional information |
---|---|---|
You are not connected to a database | Not connected to remote database | |
connecting to database: invalid database: dbname | error in database name | |
dbname=# | Connected to specific database |
Examples
Connect with API key
fbsql --host="https://cloud.featurebase.com" \
--api-key="<your-api-key-here>"
Connect with user credentials
fbsql --host="https://cloud.featurebase.com" \
--email="<your-account-email-address-here>" \
--password="<your-account-password-here>"
Connect with API key in file
Source file: cloud-api-connect.toml
host = "https://query.featurebase.com"
api-key="asdf-f345-sg-hjyjk-345323"
Connection string:
fbsql --config=cloud-user-connect.toml
Connect with user credentials in file
Source file: cloud-user-connect.toml
host = "https://query.featurebase.com"
email = 'user@example.com'
password = 'a1b2c3d4e5f6'
Connection string:
fbsql --config=cloud-user-connect.toml