From 29b0de2210440c7a2490482877458d0f3c9fd64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 3 Mar 2016 13:49:24 +0100 Subject: [PATCH] FAQ: How do I close a database connection? --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index f96eaed75..e7450ac7f 100644 --- a/README.md +++ b/README.md @@ -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 ===========