Create the connection

Stay organized with collections Save and categorize content based on your preferences.

Create the connection to Cloud Bigtable.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

C#

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

// BigtableTableAdminClient API lets us create, manage and delete tables.
BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();

// BigtableClient API lets us read and write to a table.
BigtableClient bigtableClient = BigtableClient.Create();

C++

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

cbta::BigtableTableAdminClient table_admin(
    cbta::MakeBigtableTableAdminConnection());

Go

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

adminClient, err := bigtable.NewAdminClient(ctx, *project, *instance)
if err != nil {
	log.Fatalf("Could not create admin client: %v", err)
}

Java

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

// Creates the settings to configure a bigtable data client.
BigtableDataSettings settings =
    BigtableDataSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId).build();

// Creates a bigtable data client.
dataClient = BigtableDataClient.create(settings);

// Creates the settings to configure a bigtable table admin client.
BigtableTableAdminSettings adminSettings =
    BigtableTableAdminSettings.newBuilder()
        .setProjectId(projectId)
        .setInstanceId(instanceId)
        .build();

// Creates a bigtable table admin client.
adminClient = BigtableTableAdminClient.create(adminSettings);

Node.js

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

const bigtableClient = new Bigtable();
const instance = bigtableClient.instance(INSTANCE_ID);

PHP

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

/** Uncomment and populate these variables in your code */
// $projectId = 'The Google project ID';
// $instanceId = 'The Bigtable instance ID';
// $tableId = 'The Bigtable table ID';

$instanceAdminClient = new BigtableInstanceAdminClient();
$tableAdminClient = new BigtableTableAdminClient();
$dataClient = new BigtableClient([
    'projectId' => $projectId,
]);

Python

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

# The client must be created with admin=True because it will create a
# table.
client = bigtable.Client(project=project_id, admin=True)
instance = client.instance(instance_id)

Ruby

To learn how to install and use the client library for Bigtable, see Bigtable client libraries.

# instance_id      = "my-instance"
# table_id         = "my-table"
# column_family    = "cf"
# column_qualifier = "greeting"

bigtable = Google::Cloud::Bigtable.new

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.