Skip to content

Commit

Permalink
F2022 at UWindsor
Browse files Browse the repository at this point in the history
  • Loading branch information
hosseinfani committed Jan 8, 2023
1 parent 6d00aea commit 1a0dbb4
Show file tree
Hide file tree
Showing 33 changed files with 71 additions and 0 deletions.
Binary file added Analysis/Labs_Midterm_Final_Total_Charts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Assistants/Duties_Info.xlsx
Binary file not shown.
Binary file not shown.
Binary file added Labs/Lab3/Lab3_Manual.pdf
Binary file not shown.
Binary file added Labs/Lab4/Lab4_Manual.pdf
Binary file not shown.
Binary file added Labs/Lab5/Lab5_Manual.pdf
Binary file not shown.
71 changes: 71 additions & 0 deletions Labs/Lab5/Main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <stdio.h>
#include <sqlite3.h>

static int callback(void* data, int argc, char** argv, char** ColName){

for(int i = 0; i<argc; i++){
printf("%s = %s\n", ColName[i], argv[i]);
}

return 0;
}


int main(int argc, char* argv[]) {
sqlite3* db;
int c;

c = sqlite3_open_v2("Moviesion.db", &db, SQLITE_OPEN_READWRITE, NULL);

if(c) {
printf("Can't open database! %s\n", sqlite3_errmsg(db));
return(0);
} else {
printf("Connect to database successfully.\n");
}

char* errMsg = 0;
//create SQL statement
char* sql = "CREATE TABLE Movie(" \
"ID INTEGER PRIMARY KEY NOT NULL," \
"TITLE VARCHAR(255) NOT NULL);";

//execute SQL statement
int r = sqlite3_exec(db, sql, NULL, 0, &errMsg);

if( r != SQLITE_OK ){
printf("SQL error: %s\n", errMsg);
sqlite3_free(errMsg);
}
else {
printf("Table created successfully\n");
}

sql = "INSERT INTO Movie(Id, Title) VALUES(330, 'Psycho');";

//execute SQL statement
r = sqlite3_exec(db, sql, NULL, 0, &errMsg);

if( r != SQLITE_OK ){
printf("SQL error: %s\n", errMsg);
sqlite3_free(errMsg);
}
else {
printf("Movie inserted successfully\n");
}

sql = "SELECT * from Movie";

//execute SQL statement
r = sqlite3_exec(db, sql, callback, 0, &errMsg);

if( r != SQLITE_OK ){
printf("SQL error: %s\n", errMsg);
sqlite3_free(errMsg);
}
else {
printf("Movies are retrieved successfully\n");
}

sqlite3_close(db);
}
Binary file added Labs/Lab5/Moviesion.db
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Lectures/Lec08_Algebra_Sql/Slides/Lec08B_SQL.pdf
Binary file not shown.
Binary file added Lectures/Lec09_Sql/Slides/Lec09A_SQL.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 1a0dbb4

Please sign in to comment.