comparison deita/d_connection.c @ 75:ae6a88e6e484

[Deita] Simple DB connection lib.
author June Park <parkjune1995@gmail.com>
date Wed, 31 Dec 2025 11:20:08 -0800
parents
children
comparison
equal deleted inserted replaced
74:4b96794c8d59 75:ae6a88e6e484
1 #include "deita_internal.h"
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 Deita_Connection* Deita_Connection_Create(
6 Deita_Database_Type database_type,
7 const char *connection_string)
8 {
9 if (database_type == DEITA_DATABASE_TYPE_SQLITE3)
10 return deita__sqlite_connection_create(connection_string);
11
12 fprintf(stderr, "Deita_Connection_Create: Unsupported database type %d\n", database_type);
13 return NULL;
14 }
15
16 void Deita_Connection_Close(Deita_Connection *p_connection)
17 {
18 if (!p_connection)
19 return;
20
21 if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
22 {
23 deita__sqlite_connection_close(p_connection);
24 return;
25 }
26
27 fprintf(stderr, "Deita_Connection_Close: Unsupported database type %d\n", p_connection->database_type);
28 }
29
30 boolean Deita_Connection_Is_Open(Deita_Connection *p_connection)
31 {
32 if (!p_connection)
33 return FALSE;
34
35 if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
36 return deita__sqlite_connection_is_open(p_connection);
37
38 fprintf(stderr, "Deita_Connection_Is_Open: Unsupported database type %d\n", p_connection->database_type);
39 return FALSE;
40 }