How do I connect to a FeatureBase Community database with fbsql?
Connect to a FeatureBase Community database with fbsql.
Before you begin
- Learn about “docopt” notation standards used in this guide
- Learn about fbsql
- Create a FeatureBase Community database
Enter
fbsql --help
at the CLI to list available commands.\q
quits the fbsql interface.
Syntax
(<cli-prefix>)
(
(--host="<community-hostname" / -[p|-port]=<port> ) |
--config=<filename.toml>
)
[
-[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
fbsql automatically connects to a local instance of FeatureBase Community
Argument | Description | Requires | Default | Additional information |
---|---|---|---|---|
--host="<hostname>" | Specifies remote host name IP address or URL of the machine on which FeatureBase is running. Defaults to localhost . | port specification | localhost | |
-p --port | Specify TCP port or local Unix-domain socket file extension on which FeatureBase is listening for connections. | Host specification. Defaults to 10101 | Set port in featurebase.conf configuration | |
--config=filename.toml | Designate a TOML file containing connection details | TOML connection file |
Optional arguments
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
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 |
---|---|---|
Detected on-prem, classic deployment | FeatureBase Community started Host:http:// | Manage FeatureBase Community systemctl service |
Could not detect deployment Host:http:// | FeatureBase Community service stopped | Manage FeatureBase Community systemctl service |
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 to FeatureBase community database
fbsql --host="localhost" \ --port="10101"
Connect with host/port in file
Source file local.toml
host = "localhost"
port = "10101"
Connection string:
fbsql --config=local.toml