src/DriverManager.h
branchv_0
changeset 36 91cb012d779a
parent 34 24c05e69d68f
child 37 3de41719d7eb
--- a/src/DriverManager.h	Mon May 25 21:11:17 2020 +0200
+++ b/src/DriverManager.h	Sun May 31 16:56:07 2020 +0200
@@ -17,17 +17,26 @@
 #pragma once
 
 #include <vector>
+#include <map>
 #include <codecvt>
 #include <locale>
 
 #include <relpipe/reader/typedefs.h>
 
 #include "SqlException.h"
+#include "Connection.h"
 
 namespace relpipe {
 namespace tr {
 namespace sql {
 
+/**
+ * Common principles in this SQL layer:
+ *  - Numbering starts with 1, not 0. First parameter or column = 1.
+ *  - If you got a pointer returned from a method or function, you are then responsible for given object.
+ *    Wrapping it immediatelly in a smart pointer is a convenient way to manage its lifecycle.
+ *    Statements should be destroyed before the Connection. And Connection should be destroyed before DriverManager.
+ */
 class DriverManager {
 private:
 	void* env;
@@ -44,6 +53,9 @@
 	DriverManager();
 	virtual ~DriverManager();
 	std::vector<DataSource> getDataSources();
+	Connection* getConnectionByDSN(relpipe::reader::string_t dataSourceName, relpipe::reader::string_t userName = L"", relpipe::reader::string_t password = L"");
+	Connection* getConnectionByString(relpipe::reader::string_t connectionString);
+	relpipe::reader::string_t buildDSN(const std::map<relpipe::reader::string_t, relpipe::reader::string_t>& parameters);
 };
 
 }