October 20th, 2012, 10:54 AM
I am supposed to write a program that based on the input creates or opens a database and updates it.
We use only simple input and I am able to recognize, what the user wants to do, but the problem comes when I try to open/create a db and write into it. We should use SQLite3 and yes, I have read the documentation, but it does not seem to help me.
I use the sqlite3.h header.
Now I would like to create a database and write into it and I donīt even know where to begin. If anyone could point me in the right direction, I would be very grateful. Thanks
P.S.: I know SQL, just donīt know how to use it here...
October 20th, 2012, 12:35 PM
Having written a program that connects to oracle, and uses the programming interface, I'll suggest a different method. Run sqlite3 in a separate process and communicate with it using the sql commands you already know. The trick will be to parse sqlite3 output so that you know when it's ready for the next command. I don't have time now to provide an example.
[/code] are essential for python code and Makefiles!
October 21st, 2012, 07:13 AM
You need to visit a sqllite forum.
October 21st, 2012, 09:40 PM
You first have to open the database or create it if it doesn't exist. The sqlite3_open function will do that for you. db is an example of the SQLite db handle; Check the return code to verify that the function executed successfully.
Since you already know SQL, write a SQL statement to create your table and use sqlite3_exec to execute the SQL statement.
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
Next build a SQL statement to insert you data into the table and again use sqlite3_exec to execute that SQL statement.
Finally, use sqlite3_close(db) to close the database