@@ -34,46 +34,44 @@ syntax _and_ intent.
3434``` swift
3535import SQLite
3636
37- let db = Database (" path/to/db.sqlite3" )
37+ let db = try Connection (" path/to/db.sqlite3" )
3838
39- let users = db[ " users" ]
39+ let users = Table ( " users" )
4040let id = Expression< Int64 > (" id" )
4141let name = Expression< String ?> (" name" )
4242let email = Expression< String > (" email" )
4343
44- db.create ( table : users) { t in
44+ try db.run ( users. create { t in
4545 t.column (id, primaryKey : true )
4646 t.column (name)
4747 t.column (email, unique : true )
48- }
48+ })
4949// CREATE TABLE "users" (
5050// "id" INTEGER PRIMARY KEY NOT NULL,
5151// "name" TEXT,
5252// "email" TEXT NOT NULL UNIQUE
5353// )
5454
55- var alice: Query?
56- if let rowid = users.insert (name <- " Alice" , email <- " alice@mac.com" ).rowid {
57- println (" inserted id: \( rowid ) " )
58- // inserted id: 1
59- alice = users.filter (id == rowid)
60- }
55+ let insert = users.insert (name <- " Alice" , email <- " alice@mac.com" )
56+ let rowid = try db.run (insert)
6157// INSERT INTO "users" ("name", "email") VALUES ('Alice', 'alice@mac.com')
6258
63- for user in users {
59+ for user in db. prepare ( users) {
6460 println (" id: \( user[id] ) , name: \( user[name] ) , email: \( user[email] ) " )
6561 // id: 1, name: Optional("Alice"), email: alice@mac.com
6662}
6763// SELECT * FROM "users"
6864
69- alice? .update (email <- replace (email, " mac.com" , " me.com" ))
65+ let alice = users.filter (id == rowid)
66+
67+ try db.run (alice.update (email <- email.replace (" mac.com" , " me.com" )))
7068// UPDATE "users" SET "email" = replace("email", 'mac.com', 'me.com')
7169// WHERE ("id" = 1)
7270
73- alice? .delete ()
71+ try db. run ( alice.delete () )
7472// DELETE FROM "users" WHERE ("id" = 1)
7573
76- users.count
74+ db. scalar ( users.count ) // 0
7775// SELECT count(*) FROM "users"
7876```
7977
@@ -107,29 +105,54 @@ interactively, from the Xcode project’s playground.
107105
108106## Installation
109107
110- > _ Note:_ SQLite.swift requires Swift 1.2 (and [ Xcode] [ ] 6.3) or
111- > greater.
108+ > _ Note:_ SQLite.swift requires Swift 2 (and [ Xcode] [ ] 7) or greater.
112109>
113110> The following instructions apply to targets that support embedded
114111> Swift frameworks. To use SQLite.swift in iOS 7 or an OS X command line
115112> tool, please read the [ Frameworkless Targets] [ ] section of the
116113> documentation.
117114
118115
116+ ### Carthage
117+
118+ [ Carthage] [ ] is a simple, decentralized dependency manager for Cocoa. To
119+ install SQLite.swift with Carthage:
120+
121+ 1 . Make sure Carthage is [ installed] [ Carthage Installation ] .
122+
123+ 2 . Update your Cartfile to include the following:
124+
125+ ```
126+ github "stephencelis/SQLite.swift" "master"
127+ ```
128+
129+ 3. Run `carthage update` and [add the appropriate framework][Carthage Usage].
130+
131+
132+ [Carthage]: https://github.com/Carthage/Carthage
133+ [Carthage Installation]: https://github.com/Carthage/Carthage#installing-carthage
134+ [Carthage Usage]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application
135+
136+
119137### CocoaPods
120138
121139[CocoaPods][] is a dependency manager for Cocoa projects. To install
122140SQLite.swift with CocoaPods:
123141
124- 1 . Make sure CocoaPods is [ installed] [ CocoaPods Installation ] (SQLite.swift
125- requires version 0.37 or greater).
142+ 1. Make sure CocoaPods is [installed][CocoaPods Installation]. (SQLite.swift
143+ requires version 0.37 or greater.)
126144
127145 2. Update your Podfile to include the following:
128146
129147 ``` ruby
130148 use_frameworks!
131- pod ' SQLite.swift' , git: ' https://github.com/stephencelis/SQLite.swift.git'
132- # pod 'SQLite.swift/Cipher', git: ... # instead, for SQLCipher support
149+
150+ pod 'SQLite.swift',
151+ git: 'https://github.com/stephencelis/SQLite.swift.git'
152+
153+ # instead, for SQLCipher support
154+ pod 'SQLiteCipher.swift',
155+ git: 'https://github.com/stephencelis/SQLite.swift.git'
133156 ```
134157
135158 3. Run `pod install`.
@@ -145,16 +168,14 @@ To install SQLite.swift as an Xcode sub-project:
145168 1. Drag the **SQLite.xcodeproj** file into your own project.
146169 ([Submodule][], clone, or [download][] the project first.)
147170
148- ! [](Documentation / Resources / installation@2x.png)
171+ 
149172
150- 2 . In your target’s ** Build Phases ** , add ** SQLite ** to the ** Target
151- Dependencies ** build phase .
173+ 2. In your target’s **General** tab, click the **+ ** button under **Linked
174+ Frameworks and Libraries** .
152175
153- 3 . Add ** SQLite .framework** to the ** Link Binary With Libraries ** build
154- phase.
176+ 3. Select the appropriate **SQLite.framework** for your platform.
155177
156- 4 . Add ** SQLite .framework** to a ** Copy Files ** build phase with a
157- ** Frameworks ** destination. (Add a new build phase if need be.)
178+ 4. **Add**.
158179
159180[Frameworkless Targets]: Documentation/Index.md#frameworkless-targets
160181[Xcode]: https://developer.apple.com/xcode/downloads/
0 commit comments