-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnectors.lua
55 lines (43 loc) · 869 Bytes
/
connectors.lua
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
local util = require('query_nvim/util')
local connectors = {}
function connectors.mysql(config)
if config.user == nil then
error("connectors.mysql, config.user was not provided")
end
if config.host == nil then
error("connectors.mysql, config.host was not provided")
end
if config.database == nil then
error("connectors.mysql, config.database was not provided")
end
return function(query)
local options = {
'--table',
}
local user = {
'-u',
config.user,
}
local password = {}
if config.password ~= nil then
password = {
"-p"..config.password
}
end
local host = {
'-h',
config.host,
}
local db_query = {
'-e',
query,
config.database,
}
local args = util.concat_tables(options, user, password, host, db_query)
return {
command = "mysql",
args = args
}
end
end
return connectors