Hi Jeff
Is this you from Brisbane? Did you used to come to the meetups at the State Library?
Well anyway, I used to do something similar to what you describe, by lazy initializing the connection and also checking to see if it is open.
dbConnection
dbConnection ifNil: [ dbConenction := SQLiteConnection on: self dbFilePath ].
dbConnection isOpen ifFalse: [ dbConnection open ].
^ dbConnection
I have not noticed it being "slow", but then I use transactions wherever I can. Hope that helps.
Vince
-----Original Message-----
From: Pharo-users <
[hidden email]> On Behalf Of Jeff Gray
Sent: Friday, 13 March 2020 3:21 PM
To:
[hidden email]
Subject: [Pharo-users] Stale SQLite connection
EXTERNAL: Do not click links or open attachments if you do not recognize the sender.
In my code I'm opening a sqlite connection and keeping it open rather than opening and closing one on each transaction.
Generally it's working well.
I often save and close my image. When I then reopen the image I still have a connection and it says it's open, but using it gives me an error.
This is easily recovered. I just open a new connection.
Is there a way I can see if a connection is still good, in my code?
Or should I be opening and closing connections every transaction? I haven't benchmarked it but I'm assuming it would be slower.
I guess I could set my connection to nil in a start-up script. That would cause my code to get a new connection after a break from development.
Any recommendations?
Thanks, Jeff.
--
Sent from:
https://urldefense.com/v3/__http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html__;!!I_DbfM1H!W84lOUCjvBSA4STxHvipemoZbklbEwmIFj2p7q5hydOucrDJvxnbgHGVSI_r8LDw8X7-8fSLew$