getDataSources() can be called multiple-times, use SQL_FETCH_FIRST and SQL_FETCH_NEXT
/**
* Relational pipes
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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* environment;
std::wstring_convert<std::codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings
public:
class DataSource {
public:
relpipe::reader::string_t name;
relpipe::reader::string_t description;
};
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* getConnectionByURL(relpipe::reader::string_t connectionString);
};
}
}
}