mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-17 05:48:39 +00:00
59 lines
1.5 KiB
C++
Executable File
59 lines
1.5 KiB
C++
Executable File
/**
|
|
* Jingga
|
|
*
|
|
* @package Utils
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
#ifndef DATASTORAGE_DATBASE_CONNECTION_FACTORY_H
|
|
#define DATASTORAGE_DATBASE_CONNECTION_FACTORY_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "../DatabaseType.h"
|
|
|
|
#include "ConnectionAbstract.h"
|
|
#include "DbConnectionConfig.h"
|
|
#include "MysqlConnection.h"
|
|
#include "PostgresqlConnection.h"
|
|
#include "SQLiteConnection.h"
|
|
|
|
namespace DataStorage::Database
|
|
{
|
|
ConnectionAbstract *create_connection(DbConnectionConfig dbdata)
|
|
{
|
|
switch (dbdata.db) {
|
|
case DatabaseType::MYSQL:
|
|
return new MysqlConnection(dbdata);
|
|
case DatabaseType::PGSQL:
|
|
return new PostgresqlConnection(dbdata);
|
|
case DatabaseType::SQLSRV:
|
|
return NULL;
|
|
case DatabaseType::SQLITE:
|
|
return new SQLiteConnection(dbdata);
|
|
default:
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
void close(ConnectionAbstract *db, DbConnectionConfig dbdata)
|
|
{
|
|
switch (dbdata.db) {
|
|
case DatabaseType::MYSQL:
|
|
return ((MysqlConnection *) db)->close();
|
|
case DatabaseType::PGSQL:
|
|
return ((PostgresqlConnection *) db)->close();
|
|
case DatabaseType::SQLSRV:
|
|
return;
|
|
case DatabaseType::SQLITE:
|
|
return ((SQLiteConnection *) db)->close();
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |