This this thread should be committed.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Charles Yeomans
Sent: 04 May 2012 15:40
To: Real Studio Plugins
Subject: Re: To commit and close or to not commit and close. That is the
question.


On May 4, 2012, at 10:18 AM, David Cox wrote:

> I must confess a sin.
>
> Whenever I open my cloud-based MySQL database using the MySQL Community
plugin I open it is discrete modules (rather than once on app open), read
of write the data, then end the module i.e. no db.commit or db.close.
>
> Now this has worked fine for me and still does. BUT what is the risk?
Does RS see that I have opened but not closed the database and close it
for me? Am I taking memory away in the background leading to a future
crash? Will the RS garbage collection fix the problem for me?
>
> i.e. must you perform a db.commit and db.close every time before exiting
a module (assuming you create db in the module)? TIA
>


You should call db.Commit if the table(s) to which you're writing data
support transactions.  Probably your tables do not, in which case you're
fine.

The db object should close the connection in its destructor, so there is
no need to call db.Close unless you want to close the connection before
the db object is destroyed.  Some people advocate explicitly calling
db.Close "just to be safe", but then usually do so incorrectly.

Go forth, and sin some more.

Charles Yeomans


P.S. This list is intended for plugin developers.  Plugin use questions
will likely receive more response on the NUG list.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to