Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
T
time-slime
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Michael Rouse
time-slime
Commits
31c009bc
Commit
31c009bc
authored
Aug 19, 2018
by
Michael Rouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creating database tables
parent
6cd67232
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
30 deletions
+31
-30
timeslime.c
timeslime.c
+31
-30
No files found.
timeslime.c
View file @
31c009bc
...
...
@@ -6,40 +6,16 @@
#include "timeslime.h"
#include "sqlite3.h"
/* Variables */
static
sqlite3
*
db
;
static
char
*
database_file_path
;
/*
void setup_database(void)
{
int rc;
rc = sqlite3_open(DATABASE_FILE, &db);
/* Functions */
static
TIMESLIME_STATUS_t
_TimeSlime_CreateTables
(
void
);
printf("Yay!\n");
char *sql;
sql = "CREATE TABLE meow(" \
"ID INTEGER PRIMARY KEY AUTOINCREMENT," \
"StartTime DATETIME NOT NULL," \
"EndTime DATETIME, " \
"Hours REAL" \
")";
char *zErrMsg = 0;
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
if( rc != SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
} else {
fprintf(stdout, "Table created successfully\n");
}
}*/
/*
/**
* Initializes the Time Slime library
*/
TIMESLIME_STATUS_t
TimeSlime_Initialize
(
char
directory_for_database
[])
...
...
@@ -56,7 +32,7 @@ TIMESLIME_STATUS_t TimeSlime_Initialize(char directory_for_database[])
if
(
rc
!=
SQLITE_OK
)
return
TIMESLIME_SQLITE_ERROR
;
return
TIMESLIME_OK
;
return
_TimeSlime_CreateTables
()
;
}
/* Safely close out of the Time Slime library */
...
...
@@ -265,4 +241,29 @@ static int callback(void *NotUsed, int argc, char **argv, char **azColName) {
printf("\n");
return 0;
}
*/
\ No newline at end of file
*/
/**
* Creates the SQL tables (only if the file is new)
*/
static
TIMESLIME_STATUS_t
_TimeSlime_CreateTables
(
void
)
{
char
*
zErrMsg
=
0
;
int
rc
;
char
*
sql
;
// Create time sheet table
sql
=
"CREATE TABLE TimeSheet("
\
"ID INTEGER PRIMARY KEY AUTOINCREMENT,"
\
"HoursAdded REAL NOT NULL DEFAULT 0,"
\
"ClockInTime DATETIME DEFAULT NULL,"
\
"ClockOutTime DATETIME DEFAULT NULL,"
\
"Timestamp DATETIME DEFAULT (DATETIME('now', 'localtime'))"
\
")"
;
rc
=
sqlite3_exec
(
db
,
sql
,
NULL
,
0
,
&
zErrMsg
);
if
(
rc
!=
SQLITE_OK
)
{
return
TIMESLIME_SQLITE_ERROR
;
}
return
TIMESLIME_OK
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment