-
Notifications
You must be signed in to change notification settings - Fork 0
/
ms_access_connector.go
73 lines (50 loc) · 1.6 KB
/
ms_access_connector.go
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package internal
//TODO - Deprecate this.
/*
import (
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-adodb"
"strings"
)
//
// Implementing decoding of the so called password
//
func init() {
//platform_specific_database_services := MsAccessDatabaseDrivers{}
//contract.Register(database_driver_type, &platform_specific_database_services)
}
//
// Implementing new open function
//
func OpenMsAccessDatabase(
database_filename string) (
*MsAccessDatabaseDrivers,
error) {
var database_open_error error
var ms_access_database MsAccessDatabaseDrivers
connection_string := OleDb12ConnectionString_Prefix + database_filename
connection_string_tokens := strings.Split(connection_string, ";")
for _, connection_string_token := range connection_string_tokens {
connection_string_variable_value_pair :=
strings.
Split(connection_string_token, "=")
if len(
connection_string_variable_value_pair) > 1 &&
connection_string_variable_value_pair[0] == "Data Source" {
database_encoding, database_encoding_error := ReadEncoding(connection_string_variable_value_pair[1])
if database_encoding_error != nil {
return nil, database_encoding_error
}
connection_string = connection_string + OleDb12ConnectionString_Suffix + database_encoding + `;`
}
}
ms_access_database.Database, database_open_error = sqlx.Open(database_driver_type, connection_string)
if database_open_error != nil {
return nil, database_open_error
}
database_open_error = ms_access_database.Database.Ping()
if database_open_error != nil {
return nil, database_open_error
}
return &ms_access_database, nil
} */