Connecting to Your Database

    +

    Time to connect to your database.

    Essential Steps

    Connecting to your Capella trial will allow you to access our pre-loaded "travel sample" dataset or to load your own data. Click here for more information on the travel sample data set.

    Creating Database Credentials

    In order to connect your IDE or external application to Capella, you must define at least one set of credentials.

    [NOTE] Credentials are different from Capella users. User roles are related to the organizing of UI access, projects, and things like billing.

    Step 1
    1. Click on Cluster section on the left side.

    2. Select your cluster name.

    3. Choose the Connect tab.

    4. Scroll to Database Access and click the Manage Credentials link.

    Step 2
    1. Click the Create Database Credentials on the right.

    2. Enter a username and password.

    3. Choose All Buckets, All Scopes, and Read/Write.

    4. Enter a username and password.

    13

    Allowed IP Addresses

    You must add your own IP address to connect to your cluster.

    Step 1
    1. From the Database Credentials Screen, click on the Back button.

    2. In the Connection section, select Manage Allowed IP.

    3. Click Add Allowed IP.

    Step 2
    1. For this exercise, choose the Add Permanent IP block.

    2. Beside the IP Address/CIDR Block field, click Add My IP.

    3. The IP address your computer is currently using will be filled into the IP Address/CIDR Block field.

    4. Optionally add a descriptive comment, then click the Add IP button.

    Your IP address is saved as an Allowed IP for connecting to your cluster.

    11

    Connecting to Capella Using SDKs

    Couchbase services are exposed through the SDK. Whether you are writing key-value applications or querying via N1QL, Couchbase’s SQL language.

    The Couchbase SDKs are available for developers to access clusters using their favorite IDE. Install appropriate Couchbase SDK. For more information on SDKs go to: SDKs & Connectors

    SDK Code Examples

    Head back to the Capella UI and the Cluster section, Connect tab:

    1. Click on the SDK Examples link. Opening a flyout.

    2. Check out the samples for: Java, C, Go, .NET, Node.js, PHP, and Python.

    3. Copy and paste into your IDE.

    4. Replace username and password with your new database credentials.

    5. For bucketName, replace the entry with "travel-sample".

    From your IDE you should now be able to connect, create a JSON document, and run a Couchbase N1QL query.

    For more information Couchbase SDKs, see Docs and the SDK section of our Developer Tutorials, which include tutorials on building sample applications.

    12

    Add Your Data (Optional)

    To load your own data into Capella, do the following.

    1. Within your Cluster section of the UI, click on the Tools tab.

    2. Choose Import.

    3. In the top area, select [Import] to walk through importing JSON or CSV data to your database.

    4. For more details on importing data, click here.

    6

    If you load data into a new bucket that you have created, you will need to build an index before performing a N1QL query. (A primary index is simplest, but not recommended for production environments.)

    Do this:

    1. Go to the Query Workbench (Within Cluster, Tools).

    2. Near Settings, leave "Select a bucket" as is. Make no change.

    3. Execute "CREATE PRIMARY INDEX ON bucketName" (replace with correct name).

    Learn more about the Index Service in the documentation.

    Congratulations. You finished this part of the tutorial.