Skip to content

Commit

Permalink
can now select from multiple datasources and tables
Browse files Browse the repository at this point in the history
  • Loading branch information
judell committed Sep 16, 2023
1 parent 4aa0d9c commit 293a6ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions odbc/table_code_odbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func getSchema(ctx context.Context, dataSource string, tableName string) ([]*plu
Name: "dsn",
Type: proto.ColumnType_STRING,
Description: "Data Source Name for the ODBC connection",
Transform: transform.FromConstant("dsn"),
Transform: transform.FromQual("dsn"),
}
} else {
cols[i] = &plugin.Column{
Expand Down Expand Up @@ -137,6 +137,7 @@ func tableODBC(ctx context.Context, connection *plugin.Connection) (*plugin.Tabl
Description: dsn,
List: &plugin.ListConfig{
Hydrate: listODBC,
KeyColumns: plugin.SingleColumn("dsn"),
},
Columns: cols,
}, nil
Expand All @@ -145,7 +146,8 @@ func tableODBC(ctx context.Context, connection *plugin.Connection) (*plugin.Tabl
func listODBC(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
plugin.Logger(ctx).Debug("listODBC start")

dsn := "CData Slack Source"
dsn := d.EqualsQualString("dsn")
plugin.Logger(ctx).Debug("listODBC", "dsn", dsn)

db, err := sql.Open("odbc", "DSN="+dsn)
if err != nil {
Expand Down

0 comments on commit 293a6ed

Please sign in to comment.