{"id":32315782,"url":"https://github.com/nerdyc/squeal","last_synced_at":"2025-10-23T10:53:22.574Z","repository":{"id":19542855,"uuid":"22790992","full_name":"nerdyc/Squeal","owner":"nerdyc","description":"A Swift wrapper for SQLite databases","archived":false,"fork":false,"pushed_at":"2018-11-19T05:11:22.000Z","size":435,"stargazers_count":298,"open_issues_count":2,"forks_count":31,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-10-23T10:53:06.992Z","etag":null,"topics":["database","sql","sqlite","sqlite-database","sqlite3","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerdyc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-09T17:10:37.000Z","updated_at":"2025-10-16T17:10:06.000Z","dependencies_parsed_at":"2022-08-02T23:45:43.685Z","dependency_job_id":null,"html_url":"https://github.com/nerdyc/Squeal","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/nerdyc/Squeal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyc%2FSqueal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyc%2FSqueal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyc%2FSqueal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyc%2FSqueal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerdyc","download_url":"https://codeload.github.com/nerdyc/Squeal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdyc%2FSqueal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280606611,"owners_count":26359387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","sql","sqlite","sqlite-database","sqlite3","swift"],"created_at":"2025-10-23T10:53:16.944Z","updated_at":"2025-10-23T10:53:22.561Z","avatar_url":"https://github.com/nerdyc.png","language":"Swift","readme":"# Squeal, a Swift interface to SQLite\n\nSqueal provides access to [SQLite](http://www.sqlite.org/) databases in Swift. Its goal is to provide a\nsimple and straight-forward base API, allowing developers to build on top in ways that make sense for their apps. The\nAPI provides direct SQL access, as well as a complete set of helpers to reduce SQL drudgery. It's not a goal of this\nproject to hide SQL from the developer, or to provide a generic object-mapping on top of SQLite.\n\n\n### Features\n\n* Small, straightforward Swift interface for accessing SQLite databases via SQL.\n* Helper methods for most common types of SQL statements.\n* Easy database schema versioning and migration DSL.\n* Simple DatabasePool implementation for concurrent access to a database.\n\n\n## Basic Usage\n\n```swift\nimport Squeal\n\nlet db = Database()\n\n// Create:\ntry db.createTable(\"contacts\", definitions: [\n    \"id INTEGER PRIMARY KEY\",\n    \"name TEXT\",\n    \"email TEXT NOT NULL\"\n])\n\n// Insert:\nlet contactId = try db.insertInto(\n    \"contacts\",\n    values: [\n        \"name\": \"Amelia Grey\",\n        \"email\": \"amelia@gastrobot.xyz\"\n    ]\n)\n\n// Select:\nstruct Contact {\n    let id:Int\n    let name:String?\n    let email:String\n    \n    init(row:Statement) throws {\n        id = row.intValue(\"id\") ?? 0\n        name = row.stringValue(\"name\")\n        email = row.stringValue(\"email\") ?? \"\"\n    }\n}\n\nlet contacts:[Contact] = try db.selectFrom(\n    \"contacts\",\n    whereExpr:\"name IS NOT NULL\",\n    block: Contact.init\n)\n\n// Count:\nlet numberOfContacts = try db.countFrom(\"contacts\")\n```\n\nThe above example can be found in `Squeal.playground` to allow further exploration of Squeal's interface.\n\n\n## Migrations\n\nAny non-trivial app will need to change its database schema as features are added or updated. Unfortunately, SQLite\nprovides only minimal support for updating a database's schema. Things like removing a column or removing a `NON NULL`\nrequire the entire database to be re-created with the new schema.\n\nSqueal makes migrations easy by including a `Schema` class with a simple DSL for declaring your database migrations.\nOnce defined, the Schema can be used to migrate your database to the latest version.\n\nHere's an example:\n\n```swift\nimport Squeal\n\n// Define a Schema:\nlet AppSchema = Schema(identifier:\"contacts\") { schema in\n    // Version 1:\n    schema.version(1) { v1 in\n        // Create a Table:\n        v1.createTable(\"contacts\") { contacts in\n            contacts.primaryKey(\"id\")\n            contacts.column(\"name\", type:.Text)\n            contacts.column(\"email\", type:.Text, constraints:[\"NOT NULL\"])\n        }\n\n        // Add an index\n        v1.createIndex(\n            \"contacts_email\",\n            on: \"contacts\",\n            columns: [ \"email\" ]\n        )\n    }\n    \n    // Version 2:\n    schema.version(2) { v2 in        \n        // Arbitrary SQL:\n        v2.execute { db in\n            try db.deleteFrom(\"contacts\", whereExpr: \"name IS NULL\")\n        }        \n        // Tables can be altered in many ways.\n        v2.alterTable(\"contacts\") { contacts in\n            contacts.alterColumn(\n                \"name\",\n                setConstraints: [ \"NOT NULL\" ]\n            )\n            contacts.addColumn(\"url\", type: .Text)            \n        }\n    }\n}\n\nlet db = Database()\n\n// Migrate to the latest version:\nlet didMigrate = try AppSchema.migrate(db)\n\n// Get the database version:\nlet migratedVersion = try db.queryUserVersionNumber()\n\n// Reset the database:\ntry AppSchema.migrate(db, toVersion: 0)\n```\n\nThe above example can be found in `Migrations.playground`.\n\n\n## Installation\n\nSqueal can be installed via [Carthage](https://github.com/Carthage/Carthage) or [CocoaPods](https://cocoapods.org).\n\n\n### Carthage\n\nTo install using Carthage, simply add the following line to your `Cartfile`:\n\n    github \"nerdyc/Squeal\"\n\n\n### CocoaPods\n\nTo install using Carthage, simply add the following to the appropriate target in your `Podfile`:\n\n    pod \"Squeal\"\n\n\n\n## License\n\nSqueal is released under the MIT License. Details are in the `LICENSE.txt` file in the project.\n\n## Contributing\n\nContributions 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!\n\nThe main requirement is for new code to be tested. Nobody appreciates bugs in their database.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdyc%2Fsqueal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerdyc%2Fsqueal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdyc%2Fsqueal/lists"}