Squeal, a Swift interface to SQLite
Squeal allows SQLite databases to be created and accessed from Swift code. Squeal's goal is to make the most common SQLite tasks easy in Swift, while still providing complete access to SQLite's advanced features.
Features
- Access any SQLite database, or multiple databases at a time.
- Easy interface to select rows from a database.
- Helper methods for most common types of SQL statements.
- Compile and reuse SQL for optimal performance.
- Simple DatabasePool implementation for concurrent access to a database.
- No globals.
- Thoroughly tested with Quick and Nimble.
Installation
-
Clone this project into your project directory. E.g.:
cd ~/SwiftProject mkdir Externals git clone https://github.com/nerdyc/Squeal.git Externals/Squeal
Add
Squeal.xcodeproj
to your project by selecting the 'Add files to ...' item in the 'File' menu.-
Add
Squeal.framework
to theLink Binary With Libraries
section of app or framework'sBuild Phases
. Be careful to select the framework for your platform -- Mac or iOS.You can do this by selecting your project in XCode's Project navigator (the sidebar on the left), then select
Build Phases
for your app or framework's target. -
Add Squeal's
module.map
to your project'sImport Paths
.Within your target or project's
Build Settings
, set theImport Paths
setting to$(PROJECT_DIR)/Externals/Squeal/modules
. If you clonedSqueal
to a different location, then modify the example value to match. Build and run.
Step #4 (adding the module.map
) is necessary because SQLite is a library not a module. Swift can only import
modules, and the module.map
defines a module for SQLite so it can be imported into Swift code.
NOTE: If see an issue like "Could not build Objective-C module 'sqlite3'", ensure you have the XCode command-line tools installed. They're required for the module.map to work correctly.
Usage
To get an overview of using Squeal, please check out the playground included in the project.
License
Squeal is released under the MIT License. Details are in the LICENSE.txt
file in the project.
Contributing
Contributions and suggestions are very welcome! No contribution is too small. Squeal (like Swift) is still evolving and feedback from the community is appreciated. Open an Issue, or submit a pull request!
The main requirement is for new code to be tested. Nobody appreciates bugs in their database.
Testing
Squeal benefits greatly from the following two testing libraries: