| 1 | // |
|---|---|
| 2 | // Connector.cpp |
| 3 | // |
| 4 | // Library: SQL/SQLite |
| 5 | // Package: SQLite |
| 6 | // Module: Connector |
| 7 | // |
| 8 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
| 9 | // and Contributors. |
| 10 | // |
| 11 | // SPDX-License-Identifier: BSL-1.0 |
| 12 | // |
| 13 | |
| 14 | |
| 15 | #include "Poco/SQL/SQLite/Connector.h" |
| 16 | #include "Poco/SQL/SQLite/SessionImpl.h" |
| 17 | #include "Poco/SQL/SessionFactory.h" |
| 18 | #if defined(POCO_UNBUNDLED) |
| 19 | #include <sqlite3.h> |
| 20 | #else |
| 21 | #include "sqlite3.h" |
| 22 | #endif |
| 23 | |
| 24 | |
| 25 | const SQLiteConnectorRegistrator pocoSQLiteConnectorRegistrator; |
| 26 | |
| 27 | |
| 28 | namespace Poco { |
| 29 | namespace SQL { |
| 30 | namespace SQLite { |
| 31 | |
| 32 | |
| 33 | const std::string Connector::KEY(POCO_DATA_SQLITE_CONNECTOR_NAME); |
| 34 | |
| 35 | |
| 36 | Connector::Connector() |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | |
| 41 | Connector::~Connector() |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | |
| 46 | Poco::AutoPtr<Poco::SQL::SessionImpl> Connector::createSession(const std::string& connectionString, |
| 47 | std::size_t timeout) |
| 48 | { |
| 49 | return Poco::AutoPtr<Poco::SQL::SessionImpl>(new Poco::SQL::SQLite::SessionImpl(connectionString, timeout)); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | void Connector::registerConnector() |
| 54 | { |
| 55 | Poco::SQL::SessionFactory::instance().add(new Connector()); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | void Connector::unregisterConnector() |
| 60 | { |
| 61 | Poco::SQL::SessionFactory::instance().remove(POCO_DATA_SQLITE_CONNECTOR_NAME); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | void Connector::enableSharedCache(bool flag) |
| 66 | { |
| 67 | sqlite3_enable_shared_cache(flag ? 1 : 0); |
| 68 | } |
| 69 | |
| 70 | |
| 71 | void Connector::enableSoftHeapLimit(int limit) |
| 72 | { |
| 73 | sqlite3_soft_heap_limit(limit); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | } } } // namespace Poco::SQL::SQLite |
| 78 |