Page 1 of 1

[patch_done] How Update SQLite Blob's vom V6.6.6 >> 7.

Posted: 08.01.2012, 01:17
by mmvisual
I have store in a Blob Field photos as PNG and JPG format and they are showing in my EXE, it works fine.
(Lazarus, Zeos 6.6.6, Win & Linux)

Now, I want update the Component to Zeos V7.0 and this data are stored now in a other format, this make the Zeos component.

How can I use the old Data?
Or
What must I program for a conversion routine?

See this Thread:
http://zeos.firmos.at/viewtopic.php?p=12423#12423

Q.Properties.Append('OldBlobEncoding=true');
have just no effect.

Thank for Help!
Best regards, Markus.

PS: There is no problem on MySQL, only SQLite.

Posted: 29.02.2012, 21:58
by mdaems
OldBlobEncoding
I can't find a reference to this option in the current zeoslib code. So I'm afraid someone has to write it. An alternative is writing an unload prog using zeos 6.6.6 and an upload prog using zeos 7.x.

I'm willing to merge a reasonable patch into the zeos 7 code. But I'm not going to write it myself.

Mark

Posted: 03.03.2012, 15:34
by EgonHugeist
Mark, this "OldBlobEncoding " seems like a improvement which somebody told him before. I think it was used while switching from the old slow encoding-algorythm to the new much fater once. The both algorythms are still present in the ZSQLiteUtils.pas but they are unused. I'll patch this the next day's...

EgonHugeist

Posted: 07.04.2012, 20:07
by EgonHugeist
Patch aviable in testing-egonhugeist Revision 1135.

Use 'OldBlobEncoding=True' in the TZConnection.Properties.

best regards

Posted: 14.04.2012, 21:44
by mmvisual
Hello Egon,

I have look into the databytes and analyse the difference betreen the versions 6.6.6 and 7.
In 6.6.6 was a $00 a '%0' and a '%' a '%%'. It is looking simple.

With this routine can I correct my table and do an update:

q.SQL.Text := 'SELECT * FROM foto'; // TZQuery
q.Open;
st := TMemoryStream.Create;
st2 := TMemoryStream.Create;
bOK := True;
While Not q.EOF Do // Bild-Daten konvertieren
Begin
st.Clear;
qBild.SaveToStream(st);
If st.Size > 0 Then
Begin
st.Position := 0;
st2.Clear;
b2 := 0;
While st.Position < st.Size Do // Alle Bild-Bytes
Begin
b := st.ReadByte;
If (b <> Ord('%')) Or (b2 = 1) Then
Begin
If b2 = 1 Then
If b = Ord('0') Then
b := 0
Else If b <> Ord('%') Then
Begin
bOK := False;
Break;
end;
b2 := 0;
st2.WriteByte(b);
end Else b2 := 1;
end;
If bOK Then // Konvertierung OK, Speichern
Begin
st2.Position := 0;
q.Edit;
qBild.LoadFromStream(st2);
q.Post;
End Else Break; // Kein Datensatz mehr behandeln
end;
q.Next;
end;
q.Close;