{"id":15067015,"url":"https://github.com/sagarsdagdu/sddatabase","last_synced_at":"2026-01-28T18:32:56.807Z","repository":{"id":62453456,"uuid":"167659346","full_name":"SagarSDagdu/SDDatabase","owner":"SagarSDagdu","description":"A simple yet powerful wrapper over the famous FMDB. Provides fast and easy access to sqlite database operations in iOS eliminating all the boilerplate code. Written in Swift with ❤️","archived":false,"fork":false,"pushed_at":"2019-01-26T08:33:44.000Z","size":2269,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-21T22:20:46.878Z","etag":null,"topics":["database","database-management","fmdb","ios","ios-swift","sqlite-ios","swift-library","swift4"],"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/SagarSDagdu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-26T06:50:52.000Z","updated_at":"2019-01-28T05:32:34.000Z","dependencies_parsed_at":"2022-11-01T23:46:27.242Z","dependency_job_id":null,"html_url":"https://github.com/SagarSDagdu/SDDatabase","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SagarSDagdu%2FSDDatabase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SagarSDagdu%2FSDDatabase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SagarSDagdu%2FSDDatabase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SagarSDagdu%2FSDDatabase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SagarSDagdu","download_url":"https://codeload.github.com/SagarSDagdu/SDDatabase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822310,"owners_count":20353498,"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","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","database-management","fmdb","ios","ios-swift","sqlite-ios","swift-library","swift4"],"created_at":"2024-09-25T01:15:12.780Z","updated_at":"2026-01-28T18:32:56.752Z","avatar_url":"https://github.com/SagarSDagdu.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SDDatabase\n\n![sddatabaseicon](/sddatabase_small.png)\n\n[![Version](https://img.shields.io/cocoapods/v/SDDatabase.svg?style=flat)](https://cocoapods.org/pods/SDDatabase)\n[![License](https://img.shields.io/cocoapods/l/SDDatabase.svg?style=flat)](https://cocoapods.org/pods/SDDatabase)\n[![Platform](https://img.shields.io/cocoapods/p/SDDatabase.svg?style=flat)](https://cocoapods.org/pods/SDDatabase)\n\nSDDatabase is a simple yet powerful wrapper over the famous [FMDB](https://github.com/ccgus/fmdb). Provides fast and easy access to sqlite database operations in iOS eliminating all the boilerplate code. Written with ❤️ in Swift.\n\n## Features of  `SDDatabase` : \n- Easy to use, provides direct methods for `create`, `insert`, `update`, `delete`, `select`, and others... No need to use raw queries for the above operations\n- No worries about multi threading, as each `SDDatabase` instance has its own `FMDatabaseQueue` and all the wrapper methods are called on this queue. Create one instance in a singleton and use it throughout the application.\n- Transaction support.\n- Ability to deal with encrypted database files, uses [SQLCipher](https://www.zetetic.net/sqlcipher/)\n- No need to deal with complex resultSet objects, `SDDatabase` returns results in and array of dictionaries which can be iterated over. i.e. `[[String : Any]]`\n- All the methods are fully documented, including their example usage as well. 😎\n\nChoose `SDDatabase` for your next project which uses SQLite, or migrate over your existing projects—you'll be happy you did!\n\n## Dependencies\nSDDatabase is dependent on the **FMDB/SQLCipher** subspec of FMDB. The FMDB/SQLCipher subspec declares SQLCipher as a dependency, allowing FMDB to be compiled with the `-DSQLITE_HAS_CODEC` flag.\n\n## Installation\n\nSDDatabase is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'SDDatabase'\n```\n\n## Usage \n### Initializing a database\n````swift\nlet documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!\nlet databasePath = documentDirectoryPath.appending(\"/testdb.sqlite\")\nguard let db = Database(withPath: databasePath) else {\n  print(\"DB could not be opened\")\n  return\n}\n````\nIf the database file is encrypted, you can use the init with key method\n````swift\nDatabase(withPath: self.dbPath(), key: \"testKey\")\n````\nYou can control whether the library should log any errors or other logs to the console using the property `loggingEnabled`\n````swift\n/* Set this to false if you do not want database to log to the console */\ndb.loggingEnabled = true\n````\n\n### Creating a table (`create`)\n````swift\nlet studentSchema = \" (\"\n+ \"roll_number\" + \" INT PRIMARY KEY, \"\n+ \"name\" + \" text\"\n+ \") \"\nlet creationSuccess = db.create(table: \"student\", withSchema: studentSchema)\n````\n### Inserting a record in the table (`insert`)\n````swift\nvar studentValues = [String:Any]()\nstudentValues[\"roll_number\"] = 1\nstudentValues[\"name\"] = \"Sagar\"\nlet insertionSuccess = db.insert(intoTable: \"student\", values: studentValues)\n````\n### Selecting records from the table (`select`)\n````swift\nguard let records = db.select(fromTable: \"student\", columns: [\"roll_number\", \"name\"], whereClause: \"name = ?\", whereValues: [\"Sagar\"]) else {\n  return\n}\n\nfor record in records {\n  let rollNumber = record[\"roll_number\"] as! Int\n  let name = record[\"name\"] as! String\n  print(\"Roll number : \\(rollNumber), name is \\(name)\")\n}\n````\n\nYou can also pass offset and limit to the select method, Refer the documentation for more detailed usage\n\n### Updating a record (`update`)\n````swift\nlet updateSuccess = db.update(table: \"student\", set: [\"name\" : \"Other\"], whereClause: \"name = ?\", whereValues: [\"Sagar\"])\n````\n### Deleting a record (`delete`)\n````swift\nlet deletionSuccess = db.delete(fromtable: \"student\", where: \"roll_number = ?\", whereValues: [1])\n````\n\n### Dropping a table (`drop`)\n````swift\nlet dropSuccess = db.drop(table: \"student\")\n````\n\n### Raw queries\nThe class provides `executeQuery()` and `executeUpdate()` methods for executing raw SQL statements. Refer to the documentation for detailed usage.\n\n### Transaction management\nThe class provides `beginTransaction()`, `commitTransaction`, `rollback()` and `isInTransaction()` for handling transaction management. Refer to the documentation for detailed usage.\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first. The example project includes the usage of all the methods provided by the library.\n\n## Author\n\nSagar Dagdu, shags032@gmail.com\n\n## License\n\nSDDatabase is available under the MIT license. See the LICENSE file for more info.\n\n## Contributions\n\nAll contributions are welcome. Please fork the project to add functionalities and submit a pull request to merge them in next releases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagarsdagdu%2Fsddatabase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagarsdagdu%2Fsddatabase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagarsdagdu%2Fsddatabase/lists"}