FAQ: How do I close a database connection?

This commit is contained in:
Gwendal Roué committed 2016-03-03 13:49:24 +01:00
1 parent 49b30eb290
commit 29b0de2210
1 file changed
+9
+9
View File
@@ -101,6 +101,7 @@ dbQueue.inDatabase { db in
- [Query Interface](#the-query-interface): A swift way to generate SQL.
- [Migrations](#migrations): Transform your database as your application evolves.
- [Database Changes Observation](#database-changes-observation): Perform post-commit and post-rollback actions.
- [FAQ](#faq)
- [Sample Code](#sample-code)
@@ -2359,6 +2360,14 @@ do {
Check [TableChangeObserver.swift](https://gist.github.com/groue/2e21172719e634657dfd) for a transaction observer that notifies, on the main thread, of modified database tables. Your view controllers can listen to those notifications and update their views accordingly.
FAQ
===
- **How do I close a database connection?**
You do not explicitely close a database connection: a connection is open when a [database queue](#database-queues) is created, and closed when there is no longer any reference to that database queue, and it gets deallocated. This principle is known as [RAII](http://c2.com/cgi/wiki?ResourceAcquisitionIsInitialization).
Sample Code
===========