Search the Community
Showing results for tags 'sqlite'.
Found 11 results
-
Communicating from one thread to another and the latter "talking" to a Dbgrid.
promero posted a topic in General Help
Hello Dear Friends, I have a problem and I would like to hear your opinion. It's in Delphi 11.2 I have 2 threads, one that "prepares" emails from templates and another, which is the one that sends them. The first thread, which manufactures/prepares the emails, stores them in an 'EMAILS' table in a SQLITE database, ready to be sent. It is inside a Task class. It works ok. The second thread actually sends the emails recorded in the 'EMAILS' table to the recipients. It is based on the Thread class. With every email sent, it updates the "SENT" column from EMAILS table, with "true" value. What I need: -I need the first thread "notify" the second thread "hey, I sent you lot of new emailss, please send them": that's it: send it a signal. If the second thread don't receive that signal, let it remain paused. -That the second threads, also sends an update of the sent emails to another process. This process is simply a Dbgrid showing the EMAILS table with a Column "Sent". I want that view to update 'sent' column...that is, to shows what the second thread is doing. Some suggestions? Many thanks Friends -
hello every one ... I'm trying pagination with SQLite database using live binding with a tlistview i did try using this guide: DB Pagination and TListView question - Databases - Delphi-PRAXiS [en] (delphipraxis.net) with some modification so i added the implement of pagination on PullToRefresh of the tlistview and work's fine . the problem that .... i want to keep the items that added to the tlistview every PullToRefresh and so on the code I used, can anyone point me to the right direction. procedure TFormMain.ListView2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); begin if PullToRefreshCheck then begin if (Y-RefreshPos)>40 then begin if (FDTableTask.RecordCount < lMyMaxRecordsByPage) then exit; // FDTableTask.Disconnect; FDTableTask.FetchOptions.RecsSkip := FDTableTask.FetchOptions.RecsSkip + lMyMaxRecordsByPage; FDTableTask.Open(); Label48.Text := '...تحديث'; Label48.Visible := True; Timer3.Enabled := True; PullToRefreshCheck := False; RefreshPos := 0; end else begin Label48.Text := 'u retched the end '; end; end; bandicam_2023-01-22_20-18-24-671_(1).mp4
-
I have old app in Android. I have used uniDac to connect to sqlite database. The database is encrypted using leAES256 method. FD cannot connect to it. I need to convert database for FD. But when I use both of these in the app, Delphi gives an error : sqlite3.c:(.text+0xb5e8): multiple definition of `sqlite3_aggregate_context' (And many other errors) I know the reason for the error but how to convert the database when I can't use both of them?
-
Hi, I'd like to test drive Interbase ToGo for perf compared to my current SQLite DB on mobile apps. In real world. Does anybody know of any free tool that can convert to and from Interbase <--> SQLite? I have TMS Data Modeler, but it doesn't transfer data. Any clue would be welcome. Thanks to all Steve
-
Never worked with SQLite before and now for my project need to use it but some questions and misunderstandings came on application model (VCL). I used to use GUID data type for unique records, in SQLite table the field 'uuid' is declared as binnary 'guid', and I created a trigger to generate the value, in application in FDConnection.Params.GUIDFormat=guiBinary, but when try to execute a clean FDQuery a message shows up: [FireDAC][DatS]-10. Fixed length column [uuid] data length mismatch. Value length - [32], column fixed length - [16]. changing FDConnection.Params.GUIDFormat=guiString show up a 'Wrong guid format error'. and here is the trigger for guid generation: CREATE TRIGGER demotable_after_insert AFTER INSERT ON demotable FOR EACH ROW WHEN (NEW.uuid IS NULL) BEGIN UPDATE demotable SET uuid = lower(hex(randomblob(16))) WHERE id = NEW.id; END So the question is how to deal with guids in Delphi+SQLite? Should I generate them from application? Do I need to make some mappings? The second question is about using generators for auto incremented fields, is this possible?
-
What is a way in Delphi FMX application to apply changes in SQLite database. F.e., there is an application v 1.0 in PlayMarked with the SQLite database v 0.1. New version 1.1 of an application comes with the database v 0.2 where was added new table, removed one field etc. How Delphi do (or not do and you did it instead) those migration work? When I was developing an application in Xamarin, there was a tool and it generated a "migration" script based on changes in DB classes, then Entity framework did all hard work.
-
Hi, I am surely doing something wrong there, but I can't understand where. I wrote a FDSQLiteFunction (well more than one) All of these return me widestrings, I was expecting Currency, Date, Currency. Note, first one came from help http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.SQLite_Sample procedure TDM.FDSQLiteFunction1Calculate(AFunc: TSQLiteFunctionInstance; AInputs: TSQLiteInputs; AOutput: TSQLiteOutput; var AUserData: TObject); begin // from sample AOutput.AsCurrency := AInputs[0].AsCurrency * AInputs[1].AsInteger; end; procedure TDM.FDSQLiteFunctionAAAAMMJJ2DateCalculate( AFunc: TSQLiteFunctionInstance; AInputs: TSQLiteInputs; AOutput: TSQLiteOutput; var AUserData: TObject); var vSDate : String; vDate : TDate; begin vsDate:=AInputs[0].AsString; vDate:=EncodeDate(StrToInt(Copy(vsdate,1,4)), StrToInt(Copy(vsdate,5,2)), StrToInt(Copy(vsdate,7,2))); AOutput.AsDate:=vDate; end; procedure TDM.FDSQLiteFunctionMontantCalculate( AFunc: TSQLiteFunctionInstance; AInputs: TSQLiteInputs; AOutput: TSQLiteOutput; var AUserData: TObject); var vMontant : Currency; IMontant : String; begin IMontant:=AInputs[0].AsString; Vmontant:=StrToFloat(IMontant); if Ainputs[1].AsString='-' then vMontant:=Vmontant * -1; AOutput.AsCurrency:=vMontant; end; Don't understand why! Ok, it's at design time, but I think that matters.
-
Sqlite give the possibility to create two different ':memory:' databases and attach tables from the one database to the other. Using firedac with a ':memory:' sqlite database, is it possible to attach TFDmemtables as sqlite (virtual) tables? If so, how? Thank you in advance
- 3 replies
-
- sqlite
- tfdmemtable
-
(and 1 more)
Tagged with:
-
In Delphi Rio 10.3.3 (I've not tested this on other versions) there seems to be a parsing bug with this recursive CTE: WITH RECURSIVE example1_cte (Id, No, ParsedText, Unparsed) AS ( SELECT Id, 0 as No, '' as ParsedText, TextToParse || ',' as TextToParseWithTrailingComma FROM test1 UNION ALL -- "ALL" is not strictly necessary in this example SELECT Id, No+1, -- increment the counter for this row SUBSTR(Unparsed, 0, INSTR(Unparsed, ',') ), SUBSTR(Unparsed, INSTR(Unparsed, ',') + 1) FROM example1_cte WHERE Unparsed <> '' ) -- SELECT from the recursive cte SELECT Id, No, TRIM(ParsedText) as ParsedText FROM example1_cte WHERE ParsedText <> '' ORDER BY Id ASC, No ASC; When executed a Firedac error message appears: [FireDac][Phys][SQLite] Error: no such table column: example1_cte.Id. And yet, if the line below the UNION ALL is changed to SELECT Id+0, (I.e. just adding a zero to Id), the error message goes away, and the CTE works correctly. btw, this query works fine without the "+0" in other SQLite query processors (SQLiteStudio). I think this is a bug, but cannot locate it in JIRA. Attached is a quick and dirty example project. (Change the FDQuery1 to remove the "+0" to see the error.) I don't have 10.4 so not sure this still exists. Project1.dpr Project1.dproj Unit1.dfm Unit1.pas
-
Few months ago I prepared small demo application used FireDAC SQLite connection on an Android system. And it worked fine in an application built in Delphi 10.3. Then I updated Delphi to 10.4. And now I got: Project xxx.apk raised exception class ESQLiteNativeException with message ''. and after that: [FireDAC][Phys][SQLite] ERROR: no such table: items. Even table 'items' exists in the database file and I did not any changes in sources. Anyone had the same issue?
-
I have created a tethered app. The server needs to copy a Sqlite db and stream it to the client. I get the db with this code: procedure TfmxServer.actStreamTheDbExecute(Sender: TObject); var ms: TMemoryStream; begin ms := tmemorystream.Create; ms := dmplanner.GetDbAsStream; // get it from the datamodule ms.Position := 0; thrprofServer.SendStream(thrmanServer.RemoteProfiles.First, 'Stream_TheDB', ms); // send it to the client end; function TdmPlanner.GetDbAsStream: TMemoryStream; // datamodule var fs: TFilestream; ms: TMemoryStream; begin fs := tfilestream.Create(consqlite.Params.Values['Database'] , fmOpenRead); ms := tmemorystream.Create; try ms.loadfromstream(fs); // ms.size = 315392, file size = (315,392 bytes result := ms; // so I am getting the full db3 file. result.Position := 0; finally freeandnil(fs); freeandnil(ms); // does this kill the result? end; end; I catch the stream and to write the db with this code: procedure TfrmMobile_Client_Main.DoStreamTheDb( const Aresource: TremoteResource); var fs: TFilestream; ms: TMemoryStream; begin fs := tfilestream.Create (dmplannerclient.consqlite.Params.Values['Database'] , fmopenreadwrite or fmCreate); try ms := TMemoryStream.Create; ms := TMemoryStream(AResource.Value.AsStream); ms.Position := 0; // ms.size = 315392, so I got the whole file. ms.SaveToStream(fs); dmPlannerClient.FillLbx(lbxRecipeNames); // now fill a listbox, but when I open a query, I get // [FireDAC][Phys][SQLite] ERROR: unable to open database file. finally freeandnil(fs); freeandnil(ms); end; end; So my question is, How do I copy the db to the client and then use it on the client? Better yet, How do I an in-memory db instead of an on-disk db? I have tried setting the FDConnection filename to :memory: but that did not work. Delphi CE Rio 10.3.2 Thanks...Dan'l' +