Initial commit
FossilOrigin-Name: c53d95729c009f8f80a7d63847cef7668ff73f8af0523ab65f7734696f85399c
This commit is contained in:
		
							
								
								
									
										35
									
								
								src/ac/db.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/ac/db.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
 | 
			
		||||
#include <sqlite3.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void test_db()
 | 
			
		||||
{
 | 
			
		||||
// A prepered statement for fetching tables
 | 
			
		||||
	sqlite3_stmt *stmt;
 | 
			
		||||
//
 | 
			
		||||
// // Create a handle for database connection, create a pointer to sqlite3
 | 
			
		||||
	sqlite3 *handle;
 | 
			
		||||
	int rc = sqlite3_open("ac.sqlite3",&handle);
 | 
			
		||||
 | 
			
		||||
	if ( rc ) 
 | 
			
		||||
	{
 | 
			
		||||
		perror("sqlite");
 | 
			
		||||
		printf("Database failed\n");
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	printf ("DB RC: %i\n",rc);
 | 
			
		||||
 | 
			
		||||
	char cmd[100] = "xCREATE TABLE IF NOT EXISTS aclist (uname TEXT PRIMARY KEY,pass TEXT NOT NULL,activated INTEGER)";
 | 
			
		||||
 | 
			
		||||
	rc = sqlite3_exec(handle,cmd,0,0,0);
 | 
			
		||||
 | 
			
		||||
	printf("CT RC: %i\n",rc);
 | 
			
		||||
	const char *em = sqlite3_errmsg(handle);
 | 
			
		||||
	printf("ErrMsg: %s\n",em);
 | 
			
		||||
	return ;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user