On Nov 7, 2011, at 10:29:25, Richard Hipp wrote:

> So I think what you need to do is to first "PRAGMA page_size" on the
> read-only disk database to find out what the page size is there.  Then
> "PRAGMA page_size=N" (substituting an appropriate N) as the very first
> thing you do on the in-memory database.  Then the backup should just work.


Thank you both for the quick responses. I believe I've added what you've 
described, yet it still gives me SQLITE_READONLY when I copy it. I'll break the 
code out into a somewhat linear code flow. We have some C++ classes that handle 
database and statement paradigms. See if this looks correct.

// Open the file-based db as readonly:
        const int flags = SQLITE_OPEN_READONLY;
        const int result = sqlite3_open_v2(filepath, &m_dbh, flags, NULL);
        
        if(result == SQLITE_OK)
                sqlite3_extended_result_codes(m_dbh, 1);
        
// Get its page size:
        int     pageSize = 0;
        
        SqliteStatement  cmd("PRAGMA page_size", *this);
        
        cmd.Step();
        cmd.GetColumnInt(0, pageSize);
        
// Create mem-based db:
        const int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
        const int result = sqlite3_open_v2(filepath, &m_dbh, flags, NULL);
        
        if(result == SQLITE_OK) {
// Set its page size:
                if(pageSize > 0) {
                        SqliteStatement  cmd("PRAGMA page_size = ?", *this);
                        
                        cmd.BindToInt(1, syz);
                        cmd.Step(); 
                }
                
                sqlite3_extended_result_codes(m_dbh, 1);
        } 

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to