I am using sqlite3 version 3.6.23.1 in fedora 14.I am able to export table into the file using command prompt like this,

sqlite3 data.db

sqlite> .output sample.txt;

sqlite> select *from sample;

I want handle this case at the application level.

I am using sqlite3 open source "C" API to execute this command in application level.

execute("delete from sample:);// working fine

execute(".output sample.txt"); //Not working

its throwing error called "SQL error in sqlite3_exec: near ".": syntax error"

Please suggest me how do i create a file to import the data using this API.

Function definition of the API.

int execute(const char* fmt, ...)
{

    char *err_messg;

    int ret = 0, result = 0;

    char sql_string[1024] = ""; //this honestly needs to be more elegant; will do for now

    va_list args;

    va_start(args, fmt);

    ret = vsprintf(sql_string, fmt, args);

    va_end(args);

    printf("sql_string: %s\n", sql_string);

    if (!ret)
        result = 0;
    else
        result = 1;

    if (result != -1)
    {

        if (sqlite3_exec(db_conn, sql_string, NULL, 0, &err_messg) == SQLITE_OK)    //Actual API which will work with database.
        {
            return SUCCESS;
        }
        else
        {
            printf("\n SQL error in sqlite3_exec: %s\n", err_messg);
            return DBEXCE_FAIL;
        }
    }
    return SUCCESS;
}
Edit
Report