no such column: sqlcipher_export

118 views
Skip to first unread message

Vinay Hegde

unread,
Jan 28, 2015, 6:50:58 AM1/28/15
to sqlc...@googlegroups.com
Hi Sir,

I just downloaded trail version for commercial edition of sql static lib and integrated to Xcode.
Below is my code and but it is not recognizing sqccipher_export command. in sqllight manger tool if i try to execute manually then got "no such column: sqlcipher_export" error.



- (void) createDB {

    if(FALSE){

    NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent: @"contacts.sqlite"];

    NSLog(@"Database path....%@",databasePath);

    

    sqlite3 *contactDB;

    NSString *name = @"vinay";

    NSString *address = @"blr";

    NSString *phone = @"1234567890";

    

       

        const char *dbpath = [databasePath UTF8String];

        

        if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)

        {

            const char* key = [@"sap123" UTF8String];

            //sqlite3_key(contactDB, key, strlen(key));

            

            char *errMsg;

            

            NSString *insertSQL = [NSString stringWithFormat: @"CREATE TABLE IF NOT EXISTS CONTACTS(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, ADDRESS TEXT, PHONE TEXT)"];

            

            const char *sql_stmt = [insertSQL UTF8String];

            

            if (sqlite3_exec(contactDB, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK)

                // if(1)

            {

                NSLog(@"Failed to create table");

                

            }

            else {

                NSLog(@"Table Created.....");

                sqlite3_stmt    *statement;

                NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO CONTACTS (name, address, phone) VALUES (\"%@\", \"%@\", \"%@\")", name, address, phone];

                

                const char *insert_stmt = [insertSQL UTF8String];

                

                sqlite3_prepare_v2(contactDB, insert_stmt, -1, &statement, NULL);

                if (sqlite3_step(statement) == SQLITE_DONE)

                {

                    NSLog(@"contact added");

                } else {

                    NSLog(@"Failed to add contact");

                }

                sqlite3_finalize(statement);

            }

            sqlite3_close(contactDB);

            

        } else {

            NSLog(@"Failed to open/create database");

        }

    sqlite3 *database;

    int retCode = [self openSQLiteDB:[databasePath UTF8String] database:&database];

    if( retCode == SQLITE_OK)

    {


    

    }

    } else {

        // plain DB to encrypted sqlite DB.

        sqlite3 *unencrypted_DB;

        NSString *path_u = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent: @"contacts.sqlite"];

        

        if (sqlite3_open([path_u UTF8String], &unencrypted_DB) == SQLITE_OK) {

            NSLog(@"Database Opened");

            int res = -1;

            NSMutableString* str =  [[NSMutableString alloc]initWithString:@"encrypted"];

            NSMutableString* queryStr = [[NSMutableString alloc]initWithString:@"ATTACH DATABASE '%@' AS "];

            [queryStr appendString:str];

                //NSString * enc_databasePath = [libsDir stringByAppendingPathComponent:@"encrypted.sqlite"];

            

            NSString* de_query = [NSString stringWithFormat:queryStr,path_u];

            NSLog(@"deq: %@",de_query);

            

            const char* sqlstmt = [de_query UTF8String];

            

            res = sqlite3_exec(unencrypted_DB, sqlstmt, NULL, NULL, NULL);

         

            NSString* de_export = [NSString stringWithFormat:@"SELECT sqlcipher_export('%@');",str];

            

            const char* sqlstmt1 = [de_export UTF8String];

            

            // export database

            res = sqlite3_exec(unencrypted_DB,sqlstmt1, NULL, NULL, NULL);

            if(res == SQLITE_OK)

                NSLog (@"PASS");

            

            // Detach encrypted database

            res = sqlite3_exec(unencrypted_DB, "DETACH DATABASE encrypted;", NULL, NULL, NULL);

            

            NSLog (@"End database copying");

            sqlite3_close(unencrypted_DB);

        }

        else {

            sqlite3_close(unencrypted_DB);

            NSAssert1(NO, @"Failed to open database with message '%s'.", sqlite3_errmsg(unencrypted_DB));

            }


        

    }

}



@end


Nick Parker

unread,
Jan 28, 2015, 10:45:06 AM1/28/15
to sqlc...@googlegroups.com
Hello Vinay,

If you are unable to invoke the sqlcipher_export function, my initial
thought is that SQLCipher has not been properly integrated within your
project. To confirm, could you execute the following command and let us
know what result you get?

PRAGMA cipher_version;

It appears you have created several email threads on the mailing list
for this issue. It will be easier to manage if we can keep all
conversations of the same topic on the same email thread.
> NSString*insertSQL = [NSStringstringWithFormat: @"INSERT
> INTO CONTACTS (name, address, phone) VALUES (\"%@\", \"%@\", \"%@\")",
> name, address, phone];
>
>
>
> const char *insert_stmt = [insertSQL UTF8String];
>
>
>
> sqlite3_prepare_v2(contactDB, insert_stmt, -1,
> &statement, NULL);
>
> if (sqlite3_step(statement) == SQLITE_DONE)
>
> {
>
> NSLog(@"contact added");
>
> } else {
>
> NSLog(@"Failed to add contact");
>
> }
>
> sqlite3_finalize(statement);
>
> }
>
> sqlite3_close(contactDB);
>
>
>
> } else {
>
> NSLog(@"Failed to open/create database");
>
> }
>
> sqlite3 *database;
>
> int retCode = [self openSQLiteDB:[databasePath UTF8String]
> database:&database];
>
> if( retCode == SQLITE_OK)
>
> {
>
>
>
>
> }
>
> } else {
>
> // plain DB to encrypted sqlite DB.
>
> sqlite3 *unencrypted_DB;
>
> NSString*path_u =
> [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
> NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:
> @"contacts.sqlite"];
>
>
>
> if (sqlite3_open([path_u UTF8String], &unencrypted_DB) ==
> SQLITE_OK) {
>
> NSLog(@"Database Opened");
>
> int res = -1;
>
> NSMutableString* str =
> [[NSMutableStringalloc]initWithString:@"encrypted"];
>
> NSMutableString* queryStr = [[NSMutableString
> alloc]initWithString:@"ATTACH DATABASE '%@' AS "];
>
> [queryStr appendString:str];
>
> //NSString * enc_databasePath = [libsDir
> stringByAppendingPathComponent:@"encrypted.sqlite"];
>
>
>
> NSString* de_query = [NSString
> stringWithFormat:queryStr,path_u];
>
> NSLog(@"deq: %@",de_query);
>
>
>
> const char* sqlstmt = [de_query UTF8String];
>
>
>
> res = sqlite3_exec(unencrypted_DB, sqlstmt, NULL, NULL, NULL);
>
>
>
> NSString* de_export = [NSString stringWithFormat:@"SELECT
> sqlcipher_export('%@');",str];
>
>
>
> const char* sqlstmt1 = [de_export UTF8String];
>
>
>
> // export database
>
> res = sqlite3_exec(unencrypted_DB,sqlstmt1, NULL, NULL, NULL);
>
> if(res == SQLITE_OK)
>
> NSLog (@"PASS");
>
>
>
> // Detach encrypted database
>
> res = sqlite3_exec(unencrypted_DB, "DETACH DATABASE
> encrypted;", NULL, NULL, NULL);
>
>
>
> NSLog(@"End database copying");
>
> sqlite3_close(unencrypted_DB);
>
> }
>
> else {
>
> sqlite3_close(unencrypted_DB);
>
> NSAssert1(NO, @"Failed to open database with message '%s'.",
> sqlite3_errmsg(unencrypted_DB));
>
> }
>
>
>
>
> }
>
> }
>
>
>
> @end
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "SQLCipher Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlcipher+...@googlegroups.com
> <mailto:sqlcipher+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--
Nick Parker

signature.asc

Vinay Hegde

unread,
Jan 28, 2015, 10:51:30 PM1/28/15
to sqlc...@googlegroups.com
Hello Nick,

please see attachment. i am not getting the version.

Vinay Hegde

unread,
Jan 28, 2015, 11:38:25 PM1/28/15
to sqlc...@googlegroups.com
ok i found it its 3.2.0.

but still expot command is not working

On Wednesday, January 28, 2015 at 9:15:06 PM UTC+5:30, Nick Parker wrote:

Vinay Hegde

unread,
Jan 29, 2015, 1:25:32 AM1/29/15
to sqlc...@googlegroups.com
further open question i have before using sqlcipher in my app. i.e
1. is lib bundled with sqlite?
2. is it works on iOS 6, 7, and 8 where we have sqlite version is 3.7.13?
3. i mean if i use sqlcipher latest version 3.2 is it works for all sort of iOS version and iOS device?
4. is it works with sqlite db which is is created on 3.7 sqlite version?

William Gray

unread,
Jan 29, 2015, 9:39:50 AM1/29/15
to sqlc...@googlegroups.com
Hi Vinay,

I just updated the SQLCipher integration tutorial for iOS, I’d suggest checking that out, it should answer a few of your questions and help you get started:


Cheers,
Billy

To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
signature.asc

Vinay Hegde

unread,
Jan 29, 2015, 11:25:56 AM1/29/15
to sqlc...@googlegroups.com
Hi Billy,

I am not able to make out what addition you have made for tutorials.
Can you please answer below doubts:
further open question i have before using sqlcipher in my app. i.e
1. is lib bundled with sqlite?
2. is it works on iOS 6, 7, and 8 where we have sqlite version is 3.7.13?
3. i mean if i use sqlcipher latest version 3.2 is it works for all sort of iOS version and iOS device?
4. is it works with sqlite db which is is created on 3.7 sqlite version?

Regards,
Vinay Hegde
Reply all
Reply to author
Forward
0 new messages