mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 03:03:23 +02:00
[SF 2505290] DB connection as URI (MySQL not tested!)
This commit is contained in:
@@ -86,11 +86,14 @@ public:
|
||||
bool isTransaction();
|
||||
/// Returns true iff a transaction is in progress.
|
||||
|
||||
const std::string& connectorName();
|
||||
/// Returns the name of the connector.
|
||||
|
||||
private:
|
||||
void open();
|
||||
/// Opens a connection to the Database.
|
||||
|
||||
std::string _dbFileName;
|
||||
std::string _connector;
|
||||
sqlite3* _pDB;
|
||||
bool _connected;
|
||||
bool _isTransaction;
|
||||
@@ -110,6 +113,12 @@ inline bool SessionImpl::isTransaction()
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& SessionImpl::connectorName()
|
||||
{
|
||||
return _connector;
|
||||
}
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::SQLite
|
||||
|
||||
|
||||
|
@@ -45,7 +45,7 @@ namespace Data {
|
||||
namespace SQLite {
|
||||
|
||||
|
||||
const std::string Connector::KEY("SQLite");
|
||||
const std::string Connector::KEY("sqlite");
|
||||
|
||||
|
||||
Connector::Connector()
|
||||
|
@@ -37,6 +37,8 @@
|
||||
#include "Poco/Data/SQLite/SessionImpl.h"
|
||||
#include "Poco/Data/SQLite/Utility.h"
|
||||
#include "Poco/Data/SQLite/SQLiteStatementImpl.h"
|
||||
#include "Poco/Data/SQLite/Connector.h"
|
||||
#include "Poco/String.h"
|
||||
#include "sqlite3.h"
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -52,7 +54,8 @@ const std::string SessionImpl::ABORT_TRANSACTION("ROLLBACK");
|
||||
|
||||
|
||||
SessionImpl::SessionImpl(const std::string& fileName):
|
||||
_dbFileName(fileName),
|
||||
Poco::Data::AbstractSessionImpl<SessionImpl>(fileName),
|
||||
_connector(toLower(Connector::KEY)),
|
||||
_pDB(0),
|
||||
_connected(false),
|
||||
_isTransaction(false)
|
||||
@@ -103,7 +106,7 @@ void SessionImpl::rollback()
|
||||
|
||||
void SessionImpl::open()
|
||||
{
|
||||
int rc = sqlite3_open(_dbFileName.c_str(), &_pDB);
|
||||
int rc = sqlite3_open(connectionString().c_str(), &_pDB);
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user