26 end |
26 end |
27 end |
27 end |
28 |
28 |
29 -- no drivers available |
29 -- no drivers available |
30 if table.maxn(available) < 1 then |
30 if table.maxn(available) < 1 then |
31 return '(None)' |
31 available = {'(None)'} |
32 end |
32 end |
33 |
33 |
34 return table.concat(available, ',') |
34 return available |
35 end |
35 end |
36 |
36 |
37 -- High level DB connection function |
37 -- High level DB connection function |
38 -- This should be used rather than DBD.{Driver}.New |
38 -- This should be used rather than DBD.{Driver}.New |
39 function Connect(driver, ...) |
39 function Connect(driver, ...) |
40 local modulefile = name_to_module[driver] |
40 local modulefile = name_to_module[driver] |
41 |
41 |
42 if not modulefile then |
42 if not modulefile then |
43 error(string.format("Driver '%s' not found. Available drivers are: %s", driver, available_drivers())) |
43 local available = table.concat(available_drivers(), ',') |
|
44 error(string.format("Driver '%s' not found. Available drivers are: %s", driver, available)) |
44 end |
45 end |
45 |
46 |
46 local m, err = pcall(require, modulefile) |
47 local m, err = pcall(require, modulefile) |
47 |
48 |
48 if not m then |
49 if not m then |
49 -- cannot load the module, we cannot continue |
50 -- cannot load the module, we cannot continue |
50 error(string.format('Cannot load driver %s. Available drivers are: %s', driver, available_drivers())) |
51 local available = table.concat(available_drivers(), ',') |
|
52 error(string.format('Cannot load driver %s. Available drivers are: %s', driver, available)) |
51 end |
53 end |
52 |
54 |
53 local class_str = string.format('DBD.%s.Connection', driver) |
55 local class_str = string.format('DBD.%s.Connection', driver) |
54 |
56 |
55 local connection_class = package.loaded[class_str] |
57 local connection_class = package.loaded[class_str] |