diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deita/d_connection.c	Wed Dec 31 11:20:08 2025 -0800
@@ -0,0 +1,40 @@
+#include "deita_internal.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+Deita_Connection* Deita_Connection_Create(
+  Deita_Database_Type database_type,
+  const char *connection_string)
+{
+  if (database_type == DEITA_DATABASE_TYPE_SQLITE3)
+    return deita__sqlite_connection_create(connection_string);
+
+  fprintf(stderr, "Deita_Connection_Create: Unsupported database type %d\n", database_type);
+  return NULL;
+}
+
+void Deita_Connection_Close(Deita_Connection *p_connection)
+{
+  if (!p_connection)
+    return;
+
+  if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
+  {
+    deita__sqlite_connection_close(p_connection);
+    return;
+  }
+
+  fprintf(stderr, "Deita_Connection_Close: Unsupported database type %d\n", p_connection->database_type);
+}
+
+boolean Deita_Connection_Is_Open(Deita_Connection *p_connection)
+{
+  if (!p_connection)
+    return FALSE;
+
+  if (p_connection->database_type == DEITA_DATABASE_TYPE_SQLITE3)
+    return deita__sqlite_connection_is_open(p_connection);
+
+  fprintf(stderr, "Deita_Connection_Is_Open: Unsupported database type %d\n", p_connection->database_type);
+  return FALSE;
+}