BobW 0 Posted April 14, 2022 How to deploy a simple Win 32 app with SQLite file? I just want to be able to set up the deployment to be able to create an executable Windows 32 bit app that has one Sqlite file that I can copy to another machine and execute. Is there a simple way of doing that? Share this post Link to post
Tom F 83 Posted April 14, 2022 Bob, it's not clear to me what you're asking. Are you saying you have two files 1. MyProgram.exe and 2. sqllite.dll And you want to have create an installer that installs these two files on your target machine? Look into Inno, a free installer that many, many of us use. Share this post Link to post
BobW 0 Posted April 14, 2022 MyProgram.exe and database.db are what I am trying to install on a naive machine and have it run the *exe using the SQLite *.db file locally. Share this post Link to post
SwiftExpat 65 Posted April 14, 2022 You just need to adjust the path on the db connection to allow for the path on the new machine. Options: TPath to build the path --preferred fdcsqlite.Params.Database := TPath.Combine(TPath.GetHomePath, 'RTTKCaddie.db'); adjust the file name to mydbfile.db with no directory and put it in the same directory as the exe fdcsqlite.Params.Database := 'RTTKCaddie.db'; Share this post Link to post
Cristian Peța 103 Posted April 14, 2022 Then you need to statically link SQLite code in your executable. UniDAC can do this if you set Direct=True. @SwiftExpat does FireDAC is doing the same? Share this post Link to post
SwiftExpat 65 Posted April 14, 2022 2 minutes ago, Cristian Peța said: does FireDAC is doing the same? Default in Firedac is to static link. To change it you add a TFDPhysSQLiteDriverLink component and then set the option. 4 minutes ago, Cristian Peța said: Then you need to statically link SQLite code in your executable. Valid point, depending on the data layer it is something to consider. Share this post Link to post
Uwe Raabe 2057 Posted April 14, 2022 You can even link the database into the exe as a resource and write it to disk if it doesn't exist. Share this post Link to post
BobW 0 Posted April 14, 2022 If I use this code it doesn't find my table within my database: DriversConnection.DriverName:='SQLite'; DriversConnection.ConnectionDefName:='Drivers'; DriversConnection.Params.Database:='Drivers.db'; DriversConnection.Params.DriverID:='SQLite'; DriversConnection.Open; Share this post Link to post
Uwe Raabe 2057 Posted April 14, 2022 43 minutes ago, BobW said: DriversConnection.ConnectionDefName:='Drivers'; What are the settings in the connection definition with name Drivers? Share this post Link to post
SwiftExpat 65 Posted April 14, 2022 41 minutes ago, BobW said: If I use this code it doesn't find my table within my database: Sounds like it is not finding the database file, do it is starting with an empty database. Is the Drivers.db in the same directory as the EXE? If yes, then you need to set the working directory. Test it by going to a command line and running the Exe, and make sure in dir *.db your file shows. Share this post Link to post
BobW 0 Posted April 15, 2022 Thanks for all of the suggestions. I looked at Inno Setup and it looks like easiest way to deploy a simple Win32 application with a SQLite database file. What settings would I need in my TFDConnection so that it looks locally where it is installed? Just use Inno Setup with the exe and db file, so that the applications looks in the same location as the exe file. Share this post Link to post
Uwe Raabe 2057 Posted April 15, 2022 Set Params.Database to $(RUN)\Drivers.db Share this post Link to post
BobW 0 Posted April 15, 2022 Uwe, Thanks for the response. Could you go into more detail for this: Set Params.Database to $(RUN)\Drivers.db How do I use the above? Is that hard coded in the application or a macro definition in Inno SetUp? Share this post Link to post
KenR 29 Posted April 15, 2022 e.g. {$IF DEFINED(IOS) or DEFINED(ANDROID)} FDConnection.Params.Database:=TPath.Combine(TPath.GetDocumentsPath,'xxx.db'); {$ELSE} FDConnection.Params.Database:=ExtractFilePath(ParamStr(0))+'xxx.db'; {$ENDIF} FDConnection.Connected:=True; Share this post Link to post
BobW 0 Posted April 15, 2022 I can't find TPath component. Or is it not a component? Share this post Link to post
Uwe Raabe 2057 Posted April 15, 2022 1 hour ago, BobW said: How do I use the above? Is that hard coded in the application or a macro definition in Inno SetUp? You showed a screenshot of the Object Inspector for the TFDConnection. There can be seen the Params.Database value with c:\temp\drivers.db. Change that to $(RUN)\Drivers.db and your program will look for Drivers.db in the folder where the exe is. (I don't know how to explain it better.) Share this post Link to post
BobW 0 Posted April 15, 2022 When I put $(RUN)\Drivers.db in TFDConnection.Params.Database the application gives me an error saying it can't find the Drivers2 table anymore. Sorry........ Share this post Link to post
BobW 0 Posted April 16, 2022 Ok, now when I put the application on another machine it says I need a driver definition file.................. How do I create one of those and where do I tell the application to use it? Share this post Link to post
Uwe Raabe 2057 Posted April 16, 2022 7 hours ago, BobW said: Ok, now when I put the application on another machine it says I need a driver definition file.................. That is because you give a ConnectionDefName: On 4/14/2022 at 6:01 PM, BobW said: DriversConnection.ConnectionDefName:='Drivers'; The given value is the name of an entry in the definition file with the required values for that connection. My first question was targeting exactly that, simply because you gave most of the entries in your code as well - so why the def name. If you remove this assignment in your code as well as in the object inspector of the connection, this message should disappear. Share this post Link to post
Uwe Raabe 2057 Posted April 16, 2022 9 hours ago, BobW said: When I put $(RUN)\Drivers.db in TFDConnection.Params.Database the application gives me an error saying it can't find the Drivers2 table anymore. Well, I cannot see what db is in the exe path and what tables it contains. The $(RUN) variable is simply expanded to the path of the exe file. So the cause of your problem is most likely the db found in that folder. Note that the $(RUN) expansion will only give correct results at runtime and not while in the designer. Share this post Link to post
weirdo12 19 Posted April 19, 2022 On 4/15/2022 at 8:28 PM, BobW said: Ok, now when I put the application on another machine it says I need a driver definition file.................. How do I create one of those and where do I tell the application to use it? You should take some time and read this topic: Configuring Drivers (FireDAC) - RAD Studio (embarcadero.com) Share this post Link to post