C program to get SQLite version using \'SELECT\' statement in Linux
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
In this program, we will get the SQLite version using the "SELECT" statement and then print the SQLITE version on the console screen.
Program/Source Code:
The source code to get the SQLite version using the 'SELECT' statement is given below. The given program is compiled and executed successfully on Ubuntu 20.04.
Output:
In the above program, we included the sqlite3.h header file to use SQLite related functions.
Here, we used sqlite_open() function to open a specified database. In sqlite_open() function we passed the ":memory:" as a database. The ":memory:" The :memory: is a special database name using which is used to open an in-memory database.
ret = sqlite3_prepare_v2(db_ptr, "SELECT SQLITE_VERSION()", -1, &stmt, 0);
The above function is used to compile the "SELECT" statement.
ret = sqlite3_step(stmt);
The above function is used to execute the specified select statement and get the resulted record.
printf("SQLITE Version: %s\n", sqlite3_column_text(stmt, 0));
The sqlite3_column_text() function is used to get the column value from the resulted record.
sqlite3_finalize(stmt);
sqlite3_close(db_ptr);
The above functions are used to close database properly.
need an explanation for this answer? contact us directly to get an explanation for this answer