SQCloudVMIsReadOnly

bool SQCloudVMIsReadOnly (SQCloudVM *vm);

Description

The SQCloudVMIsReadOnly interface returns true if and only if the prepared statement bound to vm makes no direct changes to the content of the database file. This routine returns false if there is any possibility that the statement might change the database file. A false return does not guarantee that the statement will change the database file. This function resembles the sqlite3_stmt_readonly SQLite API.

Parameters

Return value

A bool value that indicates if the vm is readonly.

Example

int main (int argc, const char * argv[]) {
    // setup config
    SQCloudConfig config = {0};
    config.username = "myusername";
    config.password = "mypassword"

    SQCloudConnection *conn = SQCloudConnect("myproject.sqlite.cloud", SQCLOUD_DEFAULT_PORT, &config);
    if (SQCloudIsError(conn)) {
        printf("ERROR connecting: %s (%d)\n", SQCloudErrorMsg(conn), SQCloudErrorCode(conn));
        return -1;
    } else {
        printf("Connection to host OK...\n\n");
    }

    // choose a database first
    SQCloudResult *r = SQCloudExec(conn, "USE DATABASE mydatabase.sqlite;");

    // compile the INSERT SQL statement
    SQCloudVM *vm = SQCloudVMCompile(conn, "INSERT INTO table1 (col1) VALUES ('Hello World');", -1, NULL);

    // execute the previously compiled statement
    SQCloudResult *type = SQCloudVMStep(vm);

    // check if vm is readonly
    bool rc = SQCloudVMIsReadOnly(vm);
}