21#ifndef KICAD_DATABASE_CONNECTION_H
22#define KICAD_DATABASE_CONNECTION_H
46 typedef std::map<std::string, std::any>
ROW;
50 bool aConnectNow =
true );
54 bool aConnectNow =
true );
66 bool CacheTableInfo(
const std::string& aTable,
const std::set<std::string>& aColumns );
77 bool SelectOne(
const std::string& aTable,
const std::pair<std::string, std::string>& aWhere,
87 bool SelectAll(
const std::string& aTable,
const std::string& aKey,
88 std::vector<ROW>& aResults );
97 std::string
columnsFor(
const std::string& aTable );
101 std::unique_ptr<nanodbc::connection>
m_conn;
bool CacheTableInfo(const std::string &aTable, const std::set< std::string > &aColumns)
std::string m_connectionString
DATABASE_CONNECTION(const std::string &aConnectionString, int aTimeoutSeconds=DEFAULT_TIMEOUT, bool aConnectNow=true)
std::map< std::string, std::any > ROW
std::map< std::string, std::map< std::string, int > > m_columnCache
Map of table -> map of column name -> data type.
void SetCacheParams(int aMaxSize, int aMaxAge)
bool selectAllAndCache(const std::string &aTable, const std::string &aKey)
bool SelectAll(const std::string &aTable, const std::string &aKey, std::vector< ROW > &aResults)
Retrieves all rows from a database table.
std::unique_ptr< DB_CACHE_TYPE > m_cache
static const long DEFAULT_TIMEOUT
std::string columnsFor(const std::string &aTable)
DATABASE_CACHE< std::map< std::string, ROW > > DB_CACHE_TYPE
std::unique_ptr< nanodbc::connection > m_conn
bool SelectOne(const std::string &aTable, const std::pair< std::string, std::string > &aWhere, ROW &aResult)
Retrieves a single row from a database table.
std::string GetLastError() const
std::map< std::string, std::string > m_tables
const char *const traceDatabase