34 return table.concat(available, ',') |
34 return table.concat(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, name, username, password, host, port) |
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 error(string.format("Driver '%s' not found. Available drivers are: %s", driver, available_drivers())) |
44 end |
44 end |
53 local class_str = string.format('DBD.%s.Connection', driver) |
53 local class_str = string.format('DBD.%s.Connection', driver) |
54 |
54 |
55 local connection_class = package.loaded[class_str] |
55 local connection_class = package.loaded[class_str] |
56 |
56 |
57 -- Calls DBD.{Driver}.New(...) |
57 -- Calls DBD.{Driver}.New(...) |
58 return connection_class.New(name, username, password, host, port) |
58 return connection_class.New(...) |
59 end |
59 end |
60 |
60 |
61 -- Help function to do prepare and execute in |
61 -- Help function to do prepare and execute in |
62 -- a single step |
62 -- a single step |
63 function Do(dbh, sql, ...) |
63 function Do(dbh, sql, ...) |