Hi Teg,

Thanks for your snipet!

With Regards,


SHIVSHANKER S.


HCL Technologies Limited,  

Chennai-600058
Tel: +91-44-43935000 

Extn-5029 Mobile-9884656906
Email: [EMAIL PROTECTED]



-----Original Message-----
From: Teg [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 15, 2006 7:22 PM
To: Shivshankar Subramani - TLS , Chennai
Subject: Re[4]: [sqlite] Re: Re: Handling null characters in blob data


Hello Chennai,

Wednesday, November 15, 2006, 3:09:08 AM, you wrote:

SSTC> Hey I guess you should know more of compression algorithm before u 
SSTC> call one stupid........

SSTC> With Regards,


SSTC> SHIVSHANKER S.


SSTC> HCL Technologies Limited,

SSTC> Chennai-600058
SSTC> Tel: +91-44-43935000

SSTC> Extn-5029 Mobile-9884656906
SSTC> Email: [EMAIL PROTECTED]



SSTC> -----Original Message-----
SSTC> From: Gussimulator [mailto:[EMAIL PROTECTED]
SSTC> Sent: Wednesday, November 15, 2006 12:34 PM
SSTC> To: sqlite-users@sqlite.org
SSTC> Subject: Re: Re[2]: [sqlite] Re: Re: Handling null characters in blob
data


SSTC> What kind of compression algorithm leaves out null characters? every
char
SSTC> will be taking a byte, its just stupid.



SSTC> ----- Original Message ----- 
SSTC> From: "Shivshankar Subramani - TLS , Chennai" <[EMAIL PROTECTED]>
SSTC> To: <sqlite-users@sqlite.org>
SSTC> Sent: Wednesday, November 15, 2006 2:02 AM
SSTC> Subject: RE: Re[2]: [sqlite] Re: Re: Handling null characters in blob
data


SSTC> Hi Teg,

SSTC> Can u please send me the sample code

SSTC> Thanks in advance

SSTC> With Regards,


SSTC> SHIVSHANKER S.


SSTC> HCL Technologies Limited,

SSTC> Chennai-600058
SSTC> Tel: +91-44-43935000

SSTC> Extn-5029 Mobile-9884656906
SSTC> Email: [EMAIL PROTECTED]



SSTC> -----Original Message-----
SSTC> From: Teg [mailto:[EMAIL PROTECTED]
SSTC> Sent: Wednesday, November 15, 2006 3:26 AM
SSTC> To: Shivshankar Subramani - TLS , Chennai
SSTC> Subject: Re[2]: [sqlite] Re: Re: Handling null characters in blob data


SSTC> Hello Chennai,

SSTC> Tuesday, November 14, 2006, 9:20:10 AM, you wrote:


SSTC>> Hi,

SSTC>> Actually im trying to store a compressed value,which has lots of
SSTC>> null characters.When I try to store it into the database as a blob
SSTC>> item ,only the characters before null gets stored rest does not.I
SSTC>> want to store the entire compressed buffer. Is it possible?

SSTC>> BLOB Data stored in the table ->PK...

SSTC>> Expected data to be stored
SSTC>>   PK.....
SSTC>>   ...Ɲn5
SSTC>>   n»(tm)g..
SSTC>>   .è.....
SSTC>>   ..simpl
SSTC>>   e.datUT
SSTC>>   ...û.ZE
SSTC>>   û.ZEû.Z
SSTC>>   Eí'KNÃ0
SSTC>>   .?S6Hoe
SSTC>>   Eå}ã.6U
SSTC>>   "¤B¨HHå
SSTC>>   !õ..6n2
SSTC>>   ¤-.ÇÄN"
SSTC>>   r..ì8DO
SSTC>>   .â.E¤Í£
SSTC>>   [EMAIL PROTECTED]
SSTC>>   è÷÷..«
SSTC>>   Y.¬½EURHÒ
SSTC>>   Û¨«.¨.
SSTC>>   Ü.=Ê}.M
SSTC>>   Æg.ê;.
SSTC>>   .-fº|lg
SSTC>>   p-®N®;






SSTC>> Shivshankar Subramani - TLS , Chennai 
SSTC>> <[EMAIL PROTECTED]> wrote:
>>> I did follow the procedure to store the blob data.I have no problem
>>> in excuting it but my problem is that when my data is of the below
>>> type in memory

SSTC>> [snip]

>>> Where there are lots of null character in the buffer the sqlite fails
>>> to take them as values

SSTC>> What makes you think so? Exactly what are you doing, what results
SSTC>> do you expect, what results do you get, and how the two differ?

SSTC>> Igor Tandetnik


SSTC>>
SSTC>
----------------------------------------------------------------------------
SSTC>> -
SSTC>> To unsubscribe, send email to
SSTC>> [EMAIL PROTECTED]
SSTC>>
SSTC>
----------------------------------------------------------------------------
SSTC>> -
SSTC>> DISCLAIMER
SSTC>> The contents of this e-mail and any attachment(s) are confidential
SSTC>> and intended for the

SSTC>> named recipient(s) only. It shall not attach any liability on the
SSTC>> originator or HCL or its

SSTC>> affiliates. Any views or opinions presented in this email are 
SSTC>> solely those of the author and

SSTC>> may not necessarily reflect the opinions of HCL or its affiliates.
SSTC>> Any form of reproduction,

SSTC>> dissemination, copying, disclosure, modification, distribution and
SSTC>> / or publication of this

SSTC>> message without the prior written consent of the author of this
SSTC>> e-mail
SSTC> is strictly

SSTC>> prohibited. If you have received this email in error please delete
SSTC>> it and notify the sender

SSTC>> immediately. Before opening any mail and attachments please check
SSTC>> them for viruses and

SSTC>> defect.

SSTC>>
SSTC>
----------------------------------------------------------------------------
SSTC> -
SSTC>> To unsubscribe, send email to
SSTC>> [EMAIL PROTECTED]
SSTC>>
SSTC>
----------------------------------------------------------------------------
SSTC> -

SSTC> I store JPG files in Sqlite DB's without any issues. You can't treat
them
SSTC> like text though which is what it sounds like you're doing. You really
have
SSTC> two choices, encode them as text using something like UU, Mime or
Sqlite's
SSTC> built in encoding or used the advanced API calls to bind the binary
data as
SSTC> blobs when inserting and retrieving them using the same mechanism.

SSTC> I use the later, compile the query with parameters and bind the blobs
of
SSTC> binary data after the fact before I insert.

SSTC> It's all in the API documents. I can send you sample code if you wish.

here's a simplified one

       CMD5File::MD5File(pszFile,(size_t)nLength,pMD5);
        HRESULT hr = Compile("INSERT OR IGNORE INTO Data_V2"
        "("
                "Signature," 
                "File"  
        ") VALUES (?,?);");

        BindBlob(1,pMD5,MD5_DIGEST_LENGTH);
        BindBlob(2,pszFile,static_cast<uint32_t>(nLength));

        uint32_t nResults;
        hr = Step(nResults);
        if( FAILED(hr))
        {
                FreeError();
                assert(0);
                return(E_ABORT);
        }

        ResetBindings();


        HRESULT
        CDBAutoStatement::BindBlob(uint32_t nColumn,const unsigned char*
pData,uint32_t nLength)
        {
        int nCols = sqlite3_bind_parameter_count(m_pStatement);
        if( nCols < nColumn )
        {
                assert(0);
                return(E_ABORT);
        }

        int nResults =
sqlite3_bind_blob(m_pStatement,static_cast<int>(nColumn),pData,static_cast<i
nt>(nLength), SQLITE_STATIC);
        if( nResults != SQLITE_OK)
        {
                assert(0);
                return(E_ABORT);
        }
        return(S_OK);
}


const unsigned char*
CDBAutoStatement::ColumnResultBlob(uint32_t nCol,uint32_t& nLength)
{
        nLength = sqlite3_column_bytes(m_pStatement,static_cast<int>(nCol));
        if( !nLength )
        {
                return(NULL);
        }
        return((unsigned
char*)sqlite3_column_blob(m_pStatement,static_cast<int>(nCol)));
}


I use my own wrapper but, it gives you the idea. Using paramaterized
inserts.

-- 
Best regards,
 Teg                            mailto:[EMAIL PROTECTED]


----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to