int SQCloudBlobRead (SQCloudBlob *blob, void *buffer, int blen, int offset);


The SQCloudBlobRead function is used to read data from an open BLOB handle into a caller-supplied buffer. blen bytes of data are copied into buffer buffer from the open BLOB, starting at offset offset.

This function resembles the sqlite3_blob_read SQLite API.


  • blob: a valid SQCloudBlob opaque datatype obtained by SQCloudBlobOpen
  • buffer: an user-supplied pre-allocated buffer
  • blen: the length of the input buffer
  • offset: the offset value set to where to start the read operation

Return value

-1 in case of error, otherwise it returns the len of the read operation


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;");

    // open a BLOB for reading
    SQCloudBlobOpen *blob = SQCloudBlobOpen(conn, NULL, "mytable", "mycolumn", 1, 0);

    // read from BLOB at offset 0
    char buffer[512];
    int len = SQCloudBlobRead(blob, buffer, (int)sizeof(buffer), 0);