Database Destinations

A Database Destination lets an Automation append rows to an existing table. Each destination references a credential in the Secret Store.

List Database Destinations

SDK Method

database_destination.List()

Return Values

Returns a *database_destination.Iter and an error. Range over All() to receive files_sdk.DatabaseDestination values and errors. Check each loop error before using its resource. Next() and Err() remain supported.

Authorization Requirement

Requires a Site-Wide API key, or a User API key or session from a Site Administrator or a Workspace Administrator for the relevant workspace.

Additional Arguments

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    database_destination "github.com/Files-com/files-sdk-go/v3/databasedestination"
)

databaseDestinationIterator, err := database_destination.List(files_sdk.DatabaseDestinationListParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}

for databaseDestination, err := range databaseDestinationIterator.All() {
    if err != nil {
        var respErr files_sdk.ResponseError
        if errors.As(err, &respErr) {
            fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
        } else {
            fmt.Printf("Request failed: %v\n", err)
        }
        return
    }
    fmt.Println(databaseDestination)
}

Show Database Destination

SDK Method

database_destination.Find()

Return Values

Returns a files_sdk.DatabaseDestination value and an error.

Authorization Requirement

Requires a Site-Wide API key, or a User API key or session from a Site Administrator or a Workspace Administrator for the relevant workspace.

DatabaseDestinationFindParams Fields

FieldDescription
Id
int64
Required
Database Destination ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    database_destination "github.com/Files-com/files-sdk-go/v3/databasedestination"
)

databaseDestination, err := database_destination.Find(files_sdk.DatabaseDestinationFindParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(databaseDestination)

Create Database Destination

SDK Method

database_destination.Create()

Return Values

Returns a files_sdk.DatabaseDestination value and an error.

Authorization Requirement

Requires a Site-Wide API key, or a User API key or session from a Site Administrator or a Workspace Administrator for the relevant workspace.

DatabaseDestinationCreateParams Fields

FieldDefaultDescription
Name
string
Required
Name of the destination.
Provider
string
Required
Database provider.
Possible values: snowflake, bigquery, supabase, postgresql, mysql
Config
object
Required
Provider settings for the destination. Use the schema matching provider. The connection address and table are fixed after creation.
SecretId
int64
Required
ID of a Secret in the same Workspace. Use a Token Secret for Snowflake, a service account Key/Value Secret for BigQuery, or a Username/Password Secret for a database login.
WorkspaceId
int64
0Workspace ID. 0 means the default workspace.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    database_destination "github.com/Files-com/files-sdk-go/v3/databasedestination"
)

databaseDestination, err := database_destination.Create(files_sdk.DatabaseDestinationCreateParams{
  Name: "Orders",
  Provider: "snowflake",
  Config: map[string]interface{}{"account_identifier": "value", "database_name": "value", "schema_name": "value", "table_name": "value"},
  SecretId: 1,
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(databaseDestination)

Update Database Destination

SDK Method

database_destination.Update()

Return Values

Returns a files_sdk.DatabaseDestination value and an error.

Authorization Requirement

Requires a Site-Wide API key, or a User API key or session from a Site Administrator or a Workspace Administrator for the relevant workspace.

DatabaseDestinationUpdateParams Fields

FieldDescription
Id
int64
Required
Database Destination ID.
Name
string
Name of the destination.
SecretId
int64
ID of a Secret in the same Workspace. Use a Token Secret for Snowflake, a service account Key/Value Secret for BigQuery, or a Username/Password Secret for a database login.
Config
object
Provider settings for the destination. Use the schema matching provider. The connection address and table are fixed after creation.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    database_destination "github.com/Files-com/files-sdk-go/v3/databasedestination"
)

databaseDestination, err := database_destination.Update(files_sdk.DatabaseDestinationUpdateParams{
  Id: 1,
  Name: "Orders",
})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}
fmt.Println(databaseDestination)

Delete Database Destination

SDK Method

database_destination.Delete()

Return Values

Returns an error, or nil on success.

Authorization Requirement

Requires a Site-Wide API key, or a User API key or session from a Site Administrator or a Workspace Administrator for the relevant workspace.

DatabaseDestinationDeleteParams Fields

FieldDescription
Id
int64
Required
Database Destination ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    database_destination "github.com/Files-com/files-sdk-go/v3/databasedestination"
)

err := database_destination.Delete(files_sdk.DatabaseDestinationDeleteParams{Id: 1})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Printf("API error (%s): %s\n", respErr.Type, respErr.ErrorMessage)
    } else {
        fmt.Printf("Request failed: %v\n", err)
    }
    return
}

The DatabaseDestination Object

Some of the methods above return a DatabaseDestination object. The attributes of this object are listed below.

AttributeDescription
Id
int64
Database Destination ID.
WorkspaceId
int64
Workspace ID. 0 means the default workspace.
Name
string
Name of the destination.
Provider
string
Database provider.
Possible values: snowflake, bigquery, supabase, postgresql, mysql
Config
object
Provider settings for the destination. Use the schema matching provider. The connection address and table are fixed after creation.
SecretId
int64
ID of a Secret in the same Workspace. Use a Token Secret for Snowflake, a service account Key/Value Secret for BigQuery, or a Username/Password Secret for a database login.
CreatedAt
date-time
When the destination was created.
UpdatedAt
date-time
When the destination was last updated.

config

Value typeDescription
object