-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.go
More file actions
48 lines (44 loc) · 2.12 KB
/
database.go
File metadata and controls
48 lines (44 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2019 Cuttle.ai. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Package dbtoolkit contains structures and functions required for interacting with different databases
// sub packages has the drivers for interacting with different databases
package dbtoolkit
import (
"github.com/cuttle-ai/brain/interpreter"
"github.com/sirupsen/logrus"
)
// Column holds the information about a column and its data type
type Column struct {
//Name of the column
Name string
//DataType is the data type of the column
DataType string
//DateFormat is the format of the date type if column's data type is date
DateFormat string
}
// Datastore can store data uploaded/imported by the user to cuttle platform
type Datastore interface {
//DumpCSV will dump the given csv file to the datastore.
//Default behaviour of the method will be to replace the existing data in the datastore.
//But if appendData flag is set, then existing data won't be removed instead new data will be appended to it.
DumpCSV(filename string, tablename string, columns []interpreter.ColumnNode, appendData bool, createTable bool, doScp bool, logger *logrus.Entry) error
//DeleteTable will delete the given table in the datastore
DeleteTable(tablename string) error
//Exec can execute a query and return the response as the array of interfaces
Exec(query string, args ...interface{}) ([]map[string]interface{}, error)
//GetColumnTypes returns the list of columns and their data types for a given table
GetColumnTypes(tableName string) ([]Column, error)
//ChangeColumnTypeToDate changes the data type of the given column to date with the provided date format
ChangeColumnTypeToDate(tableName string, colName string, dateFormat string) error
//Get all the tables in the datastore
GetTableNames(schemaName string) ([]string, error)
//Close the connection to the datastore
Close() error
//Ping the datastore
Ping() error
//GetDDL returns the DDL for the given table
GetDDL(tableName string) (string, error)
//GetSchemas returns the list of schemas in the datastore
GetSchemas() ([]string, error)
}