Skip to content

Commit

Permalink
It can't compile yet
Browse files Browse the repository at this point in the history
  • Loading branch information
zertmark committed Sep 17, 2024
1 parent 5a9cc7c commit 2ed321a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bot.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void startBot()
telebot_message_t message;
telebot_update_type_e update_types[] = {TELEBOT_UPDATE_TYPE_MESSAGE};
char message_reply[MESSAGE_REPLY_SIZE]= {0};
openDatabase("/root/Desktop/FinanceBot/databases/test.db");
openDatabase("./databases/path.db");
while (1)
{
telebot_update_t *updates;
Expand Down
11 changes: 9 additions & 2 deletions src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define DEFAULT_PATH "./databases/test.db"
#define DEFAULT_PATH "./databases/d1.db"
#define MAX_STRING_LINES 100

static sqlite3 *dataBase = {0};
Expand Down Expand Up @@ -216,10 +216,17 @@ void openDatabase(char *path_to_database)
sqlite3_initialize();
if (access(path_to_database, F_OK || W_OK || R_OK) == -1)
{
pritnf("[WARNING] Couldn't find existing database at databases/test.db\nUsing default database path...\n");
path_to_database = DEFAULT_PATH;
}
sqlite3_open(path_to_database, &dataBase);
if (sqlite3_open(path_to_database, &dataBase) == SQLITE_OK)
{
return;
}

createDatabase(path_to_database);
}

static int countRowsResult(sqlite3_stmt *stmt)
{
sqlite3_reset(stmt);
Expand Down

0 comments on commit 2ed321a

Please sign in to comment.