Tabelle beschreiben - Amazon Timestream

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

Tabelle beschreiben

Sie können die folgenden Codefragmente verwenden, um Informationen zu den Attributen Ihrer Tabelle zu erhalten.

Anmerkung

Diese Codefragmente basieren auf vollständigen Beispielanwendungen auf. GitHub Weitere Informationen zu den ersten Schritten mit den Beispielanwendungen finden Sie unter. Beispielanwendung

Java
public void describeTable() { System.out.println("Describing table"); final DescribeTableRequest describeTableRequest = new DescribeTableRequest(); describeTableRequest.setDatabaseName(DATABASE_NAME); describeTableRequest.setTableName(TABLE_NAME); try { DescribeTableResult result = amazonTimestreamWrite.describeTable(describeTableRequest); String tableId = result.getTable().getArn(); System.out.println("Table " + TABLE_NAME + " has id " + tableId); } catch (final Exception e) { System.out.println("Table " + TABLE_NAME + " doesn't exist = " + e); throw e; } }
Java v2
public void describeTable() { System.out.println("Describing table"); final DescribeTableRequest describeTableRequest = DescribeTableRequest.builder() .databaseName(DATABASE_NAME).tableName(TABLE_NAME).build(); try { DescribeTableResponse response = timestreamWriteClient.describeTable(describeTableRequest); String tableId = response.table().arn(); System.out.println("Table " + TABLE_NAME + " has id " + tableId); } catch (final Exception e) { System.out.println("Table " + TABLE_NAME + " doesn't exist = " + e); throw e; } }
Go
// Describe table. describeTableInput := &timestreamwrite.DescribeTableInput{ DatabaseName: aws.String(*databaseName), TableName: aws.String(*tableName), } describeTableOutput, err := writeSvc.DescribeTable(describeTableInput) if err != nil { fmt.Println("Error:") fmt.Println(err) } else { fmt.Println("Describe table is successful, below is the output:") fmt.Println(describeTableOutput) }
Python
def describe_table(self): print("Describing table") try: result = self.client.describe_table(DatabaseName=Constant.DATABASE_NAME, TableName=Constant.TABLE_NAME) print("Table [%s] has id [%s]" % (Constant.TABLE_NAME, result['Table']['Arn'])) except self.client.exceptions.ResourceNotFoundException: print("Table doesn't exist") except Exception as err: print("Describe table failed:", err)
Node.js

Der folgende Codeausschnitt wird AWS SDK für JavaScript Version 3 verwendet. Weitere Informationen zur Installation und Verwendung des Clients finden Sie unter Timestream Write Client — AWS SDK for v3. JavaScript

Siehe auch Klasse DescribeTableCommand und DescribeTable.

import { TimestreamWriteClient, DescribeTableCommand } from "@aws-sdk/client-timestream-write"; const writeClient = new TimestreamWriteClient({ region: "us-east-1" }); const params = { DatabaseName: "testDbFromNode", TableName: "testTableFromNode" }; const command = new DescribeTableCommand(params); try { const data = await writeClient.send(command); console.log(`Table ${data.Table.TableName} has id ${data.Table.Arn}`); } catch (error) { if (error.code === 'ResourceNotFoundException') { console.log("Table or Database doesn't exist."); } else { console.log("Describe table failed.", error); throw error; } }

Das folgende Snippet verwendet den AWS SDK for JavaScript V2-Stil. Es basiert auf der Beispielanwendung unter Node.js Beispiel Amazon Timestream für die LiveAnalytics Anwendung auf GitHub.

async function describeTable() { console.log("Describing Table"); const params = { DatabaseName: constants.DATABASE_NAME, TableName: constants.TABLE_NAME }; const promise = writeClient.describeTable(params).promise(); await promise.then( (data) => { console.log(`Table ${data.Table.TableName} has id ${data.Table.Arn}`); }, (err) => { if (err.code === 'ResourceNotFoundException') { console.log("Table or Database doesn't exists."); } else { console.log("Describe table failed.", err); throw err; } } ); }
.NET
public async Task DescribeTable() { Console.WriteLine("Describing Table"); try { var describeTableRequest = new DescribeTableRequest { DatabaseName = Constants.DATABASE_NAME, TableName = Constants.TABLE_NAME }; DescribeTableResponse response = await writeClient.DescribeTableAsync(describeTableRequest); Console.WriteLine($"Table {Constants.TABLE_NAME} has id:{response.Table.Arn}"); } catch (ResourceNotFoundException) { Console.WriteLine("Table does not exist."); } catch (Exception e) { Console.WriteLine("Describe table failed:" + e.ToString()); } }