DocsGetting Started

Getting started

Creating a database

When you first arrive on the Control Center page, you will have no databases. Click one of the “Create New” buttons to get started.

Screenshot of an empty Control Center

The only required setting when creating a database instance is the region. Names are optional but can help you keep track of your databases. You can expand the other optional configuration to access additional settings.

Screenshot of creating a database instance

You can select the PostgreSQL version, default database locale, and default text encoding. Click “Create Database,” to make your PostgreSQL instance immediately available. The database will appear in the Control Center.

Screenshot of creating a database instance, with additional details

The database appears in the Control Center. You can repeat this process to create additional databases. To view connection information, click to expand the database row and view additional details.

Screenshot of the first database

Connecting to the database

Once you expand the detail view of the database, you see recent activity metrics, the database identifier, and connection information.

Connecting from psql

PostgreSQL’s standard command line client is psql. Make sure you have it installed.

To connect to CrystalDB using psql, just copy the command from the database detail view and paste it into your terminal.

Screenshot of the detail view of the first database showing how to copy the psql command

When you first connect to a database instance, CrystalDB performs some initialization, which currently takes a few seconds.

Connecting from Python

Begin by locating the database connection URI in the Control Center.

Screenshot of the detail view of the first database showing how to copy the connection URI

Copy the URI and use it as an argument to your database client. Here is an example using psycopg2.

import psycopg2
 
# Define the PostgreSQL connection URI
connection_uri = "{{REPLACE WITH YOUR URI}}"
 
# Connect to the PostgreSQL database using the URI
conn = psycopg2.connect(connection_uri)
 
# Create a cursor object to interact with the database
cursor = conn.cursor()
 
# Perform the SELECT operation
cursor.execute("SELECT 'Hello from CrystalDB!'")
 
# Fetch the result
result = cursor.fetchone()
 
# Print the result
if result:
    print(result[0])
 
# Close the cursor and the database connection
cursor.close()
conn.close()

Connecting from Node.js, Java, Ruby, and other languages

Because CrystalDB runs PostgreSQL, you can access it using any programming language that has PostgreSQL client support. We will update this section to include detailed instructions for additional languages.

If your language does not support database connection URIs, you can deconstruct the URI to determine the host, database user, password, and database name. The format of the URI is:

postgres://{{DATABASE_USER}}:{{PASSWORD}}@{{HOST}}:{{PORT}}/{{DATABASE_NAME}}?sslmode=require

Note that CrystalDB requires encrypted TLS connections, which are broadly supported in recent client versions but not all older versions.

Understanding the Control Center

The CrystalDB Control Center gives you an instant overview of the health and activity of your databases. The columns are as follows:

  • Status: The states Ok, Warning, and Critical tell you whether the database is running near its configured scaling limits or shows signs of application errors or other problems warranting attention.
  • Connections: A connection is a wire-protocol connection between a client and the database service. This metric indicates the number of connections established as polled during the measurement interval.
  • Statements per second: A statement is an individual command issued to the database. When using a database interactively, you complete a statement every time you enter a semicolon. This metric indicates the number of statements executed each second averaged across the measurement interval.
  • Errors per second: When the database attempts to execute a statement and fails for any reason, we count this as an error. This metric indicates the average number of errors encountered each second.
  • Latency: Latency measures how long the database takes to process a statement. This metric shows the average latency, in seconds, measured at the database service. Your application may experience additional latency due to network transit.
  • Compute: We meter compute resources according to usage. This metric shows the amount of memory provided to the database, averaged across the interval. CPU capacity and I/O bandwidth scale together with memory, so demand for these resources can also drive this metric.
  • Storage: We meter storage according to usage. This metric shows the amount of storage for storing database files, averaged across the interval. We back up and replicate data automatically but report only the space used for the primary copy.

Limitations

  • CrystalDB is presently only available on AWS.
  • Organizations are presently limited to creating 10 databases. Databases are also limited to 1 TB of storage. You may contact us to adjust these limits.