Mercurial
comparison deita/deita.h @ 75:ae6a88e6e484
[Deita] Simple DB connection lib.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Wed, 31 Dec 2025 11:20:08 -0800 |
| parents | |
| children | f3084bca7317 |
comparison
equal
deleted
inserted
replaced
| 74:4b96794c8d59 | 75:ae6a88e6e484 |
|---|---|
| 1 #ifndef DEITA | |
| 2 #define DEITA | |
| 3 | |
| 4 #include "dowa/dowa.h" | |
| 5 | |
| 6 // Database types | |
| 7 typedef enum | |
| 8 { | |
| 9 DEITA_DATABASE_TYPE_SQLITE3 = 0 | |
| 10 // Future: DEITA_DATABASE_TYPE_POSTGRES, DEITA_DATABASE_TYPE_MYSQL | |
| 11 } Deita_Database_Type; | |
| 12 | |
| 13 // Connection handle (opaque) | |
| 14 typedef struct Deita_Connection Deita_Connection; | |
| 15 | |
| 16 // Result set (opaque) | |
| 17 typedef struct Deita_Result_Set Deita_Result_Set; | |
| 18 | |
| 19 // Column value type | |
| 20 typedef enum | |
| 21 { | |
| 22 DEITA_COLUMN_TYPE_NULL = 0, | |
| 23 DEITA_COLUMN_TYPE_INTEGER, | |
| 24 DEITA_COLUMN_TYPE_REAL, | |
| 25 DEITA_COLUMN_TYPE_TEXT, | |
| 26 DEITA_COLUMN_TYPE_BLOB | |
| 27 } Deita_Column_Type; | |
| 28 | |
| 29 // --- Connection Management --- // | |
| 30 | |
| 31 extern Deita_Connection* Deita_Connection_Create( | |
| 32 Deita_Database_Type database_type, | |
| 33 const char *connection_string | |
| 34 ); | |
| 35 | |
| 36 extern void Deita_Connection_Close(Deita_Connection *p_connection); | |
| 37 | |
| 38 extern boolean Deita_Connection_Is_Open(Deita_Connection *p_connection); | |
| 39 | |
| 40 // --- Query Execution --- // | |
| 41 | |
| 42 extern Deita_Result_Set* Deita_Query_Execute( | |
| 43 Deita_Connection *p_connection, | |
| 44 const char *query, | |
| 45 Dowa_Arena *p_arena | |
| 46 ); | |
| 47 | |
| 48 extern Deita_Result_Set* Deita_Query_Execute_Prepared( | |
| 49 Deita_Connection *p_connection, | |
| 50 const char *query, | |
| 51 int32 parameter_count, | |
| 52 const char **parameter_values, | |
| 53 Dowa_Arena *p_arena | |
| 54 ); | |
| 55 | |
| 56 extern int32 Deita_Query_Execute_Update( | |
| 57 Deita_Connection *p_connection, | |
| 58 const char *query | |
| 59 ); | |
| 60 | |
| 61 extern int32 Deita_Query_Execute_Update_Prepared( | |
| 62 Deita_Connection *p_connection, | |
| 63 const char *query, | |
| 64 int32 parameter_count, | |
| 65 const char **parameter_values | |
| 66 ); | |
| 67 | |
| 68 // --- Result Set Access --- // | |
| 69 | |
| 70 extern boolean Deita_Result_Set_Next(Deita_Result_Set *p_result_set); | |
| 71 | |
| 72 extern int32 Deita_Result_Set_Get_Column_Count(Deita_Result_Set *p_result_set); | |
| 73 | |
| 74 extern const char* Deita_Result_Set_Get_Column_Name( | |
| 75 Deita_Result_Set *p_result_set, | |
| 76 int32 column_index | |
| 77 ); | |
| 78 | |
| 79 extern Deita_Column_Type Deita_Result_Set_Get_Column_Type( | |
| 80 Deita_Result_Set *p_result_set, | |
| 81 int32 column_index | |
| 82 ); | |
| 83 | |
| 84 extern const char* Deita_Result_Set_Get_Text( | |
| 85 Deita_Result_Set *p_result_set, | |
| 86 int32 column_index | |
| 87 ); | |
| 88 | |
| 89 extern int64 Deita_Result_Set_Get_Integer( | |
| 90 Deita_Result_Set *p_result_set, | |
| 91 int32 column_index | |
| 92 ); | |
| 93 | |
| 94 extern double Deita_Result_Set_Get_Real( | |
| 95 Deita_Result_Set *p_result_set, | |
| 96 int32 column_index | |
| 97 ); | |
| 98 | |
| 99 extern void Deita_Result_Set_Free(Deita_Result_Set *p_result_set); | |
| 100 | |
| 101 #endif |