{"id":990,"url":"https://github.com/oleghnidets/OHMySQL","last_synced_at":"2025-07-30T20:32:56.136Z","repository":{"id":36869244,"uuid":"41176216","full_name":"oleghnidets/OHMySQL","owner":"oleghnidets","description":"Swift + MySQL = ❤️","archived":false,"fork":false,"pushed_at":"2024-10-07T11:12:24.000Z","size":107633,"stargazers_count":238,"open_issues_count":5,"forks_count":42,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-06-25T21:51:24.534Z","etag":null,"topics":["cocoapods","database","dbms","ios","maccatalyst","macos","mysql","mysql-c-api","mysql-client","mysqlclient","objective-c","sql","swift","tvos","watchos"],"latest_commit_sha":null,"homepage":"https://oleghnidets.github.io/OHMySQL/documentation/ohmysql/","language":"C","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/oleghnidets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"oleghnidets","custom":"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YCAKYM4XCT2DG\u0026source=url"}},"created_at":"2015-08-21T20:31:41.000Z","updated_at":"2025-05-12T15:07:11.000Z","dependencies_parsed_at":"2024-01-26T21:06:25.366Z","dependency_job_id":"2017cc6f-b01f-4fc4-bd26-09de4d0033b9","html_url":"https://github.com/oleghnidets/OHMySQL","commit_stats":{"total_commits":182,"total_committers":6,"mean_commits":"30.333333333333332","dds":"0.22527472527472525","last_synced_commit":"33f65f6a22082158a4c82cc8f56b6b888668b77d"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/oleghnidets/OHMySQL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleghnidets%2FOHMySQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleghnidets%2FOHMySQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleghnidets%2FOHMySQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleghnidets%2FOHMySQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleghnidets","download_url":"https://codeload.github.com/oleghnidets/OHMySQL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleghnidets%2FOHMySQL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267842973,"owners_count":24153133,"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-07-30T02:00:09.044Z","response_time":70,"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":["cocoapods","database","dbms","ios","maccatalyst","macos","mysql","mysql-c-api","mysql-client","mysqlclient","objective-c","sql","swift","tvos","watchos"],"created_at":"2024-01-05T20:15:36.426Z","updated_at":"2025-07-30T20:32:51.100Z","avatar_url":"https://github.com/oleghnidets.png","language":"C","readme":"# OHMySQL\n\n[![License][platform-image]][platform-url]\n[![License][license-image]][license-url]\n[![CocoaPods Compatible][cocoapods-image]][cocoapods-url]\n[![Carthage Compatible][carthage-image]][carthage-url]\n[![Documentation][docs-image]][docs-url]\n\nOHMySQL can connect to remote or local MySQL database and execute CRUD operations. The framework is built upon MySQL C API, but you don’t need to dive into low-level. The following diagram represents a general architecture. Logic (saving, editing, removing etc.) is aggregated in the app. The database is just a shared storage.\n\n\u003cp align=\"center\" \u003e⭐️ \u003cb\u003eEvery star is appreciated!\u003c/b\u003e ⭐️\u003c/p\u003e\n\n\n\u003c!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=2 depthTo=6 orderedList=false} --\u003e\n\n\u003c!-- code_chunk_output --\u003e\n\n- [Features](#-features)\n- [Platforms](#-platforms)\n- [Project Support](#-project-support)\n- [Installation](#-installation)\n- [Usage](#-usage)\n- [Query Context](#-query-context)\n  - [Execute Query](#-execute-query)\n  - [SELECT](#-select-)\n  - [INSERT](#-insert)\n  - [UPDATE](#-update)\n  - [DELETE](#-delete)\n  - [JOINs](#-joins)\n  - [Object Mapping](#-object-mapping)\n- [Communication](#-communication)\n- [License](#-license-)\n\n\u003c!-- /code_chunk_output --\u003e\n\n## Features\n\n- [x] Supports Swift and Objective-C \n- [x] Requires minimal knowledge in SQL\n- [x] Easy to integrate and use\n- [x] Many functionality features\n- [x] Up-to-date MySQL library\n- [x] [Documentation](https://oleghnidets.github.io/OHMySQL/documentation/ohmysql/) and [support](https://github.com/oleghnidets/OHMySQL/issues?q=is%3Aissue+is%3Aclosed)\n\n## Platforms\n\n| Platform    | Supported  | \n| ----------- | ---------  | \n| iOS         | 14.0+      | \n| macOS       | 11.0+      | \n| Mac Catalyst| 14.0+      | \n| watchOS     | 8.0+       | \n| tvOS        | 15.0+      |\n\n## Project Support\n\nI wish to support the library and extend API and functionality. If you donate me some money 💵, it keeps me motivated and happy 🙂 You may support me via [PayPal](\nhttps://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YCAKYM4XCT2DG\u0026source=url ) or let me know any other method convenient for you.\n\n## Installation\n\nRead [documentation](https://oleghnidets.github.io/OHMySQL/documentation/ohmysql/installation) how to install the library as a dependency in your project.\n\n## Usage\n\nConnect to the database.\n\n```swift\nlet user = MySQLConfiguration(userName: \"root\", \n                              password: \"root\", \n                            serverName: \"localhost\", \n                                dbName: \"dbname\", \n                                  port: 3306, \n                                socket: \"/mysql/mysql.sock\")\n\nlet coordinator = MySQLStoreCoordinator(user: user!)\ncoordinator.encoding = .UTF8MB4\ncoordinator.connect()\n```\nTo end a connection:\n```swift\ncoordinator.disconnect()\n```\n\n## Query Context\n\nTo execute a query you have to create the context:\n```swift\nlet context = MySQLQueryContext()\ncontext.storeCoordinator = coordinator\n```\n\n### Execute Query\n\n```swift\nlet dropQueryString = \"DROP TABLE `MyTable`\"\nlet dropQueryRequest = MySQLQueryRequest(queryString: dropQueryString)\ntry? context.execute(dropQueryRequest)\n```\n\n### SELECT \n\nThe response contains the array of the dictionaries.\n\n```swift\nlet query = MySQLQueryRequestFactory.select(\"tasks\", condition: nil)\nlet response = try? context.executeQueryRequestAndFetchResult(query)\n```\n\n### INSERT\n\n```swift\nlet query = MySQLQueryRequestFactory.insert(\"tasks\", set: [\"name\": \"Something\", \"desctiption\": \"new task\"])\ntry? context.execute(query)\n```\n\n### UPDATE\n\n```swift\nlet query = MySQLQueryRequestFactory.update(\"tasks\", set: [\"name\": \"Something\"], condition: \"id=7\")\ntry? context.execute(query)\n```\n\n### DELETE\n\n```swift\nlet query = MySQLQueryRequestFactory.delete(\"tasks\", condition: \"id=10\")\ntry? context.execute(query)\n```\n\n### JOINs\n\nYou can execute 4 types of joins - `INNER`, `RIGHT`, `LEFT`, `FULL`.\n\n```swift\nlet query = MySQLQueryRequestFactory.joinType(OHJoinInner, fromTable: \"tasks\", columnNames: [\"id\", \"name\", \"description\"], joinOn: [\"subtasks\": \"tasks.id=subtasks.parentId\"])\nlet result = try? context.executeQueryRequestAndFetchResult(query)\n```\n\n### Object Mapping\n\nYou have to implement the protocol `OHMappingProtocol` for your models. \nThe library has only a primary logic for mapping, so I would recommend you writing a mapping logic by yourself. If you are using Swift you cannot use fundamental number types (`Int`, `Double`), only `NSNumber` (due to run-time). \n\n```swift\ncontext.insertObject(task)\ntry? context.save()\n```\n\nYou can update/delete the objects easily.\n\n```swift\nlet task = Task()\ntask.name = \"sample\"\ncontext.updateObject(task)\ncontext.deleteObject(task)\n\ntry? context.save()\n```\n\n## Communication\n\n- If you found a bug, have a suggestion or need help, [open the issue](https://github.com/oleghnidets/OHMySQL/issues/new).\n- If you want to contribute, [submit a pull request](https://github.com/oleghnidets/OHMySQL/pulls).\n- If you need help, [write me](oleg.oleksan@gmail.com).\n\n## License \n\nSee [LICENSE](LICENSE).\n\n[platform-image]: https://img.shields.io/badge/platforms-ios%20|%20macOS%20|%20catalyst%20-orange.svg\n[platform-url]: https://oleghnidets.github.io/OHMySQL/documentation/ohmysql\n[license-image]: https://img.shields.io/badge/License-MIT-green.svg\n[license-url]: LICENSE\n[cocoapods-image]: https://img.shields.io/cocoapods/v/OHMySQL.svg?style=flat-square\n[cocoapods-url]: OHMySQL.podspec\n[carthage-image]: https://img.shields.io/badge/carthage-compatible-blue.svg\n[carthage-url]: https://github.com/Carthage/Carthage\n[docs-image]: https://img.shields.io/badge/documentation-DocC-lightgrey.svg\n[docs-url]: https://oleghnidets.github.io/OHMySQL/documentation/ohmysql","funding_links":["https://github.com/sponsors/oleghnidets","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YCAKYM4XCT2DG\u0026source=url"],"categories":["Database"],"sub_categories":["Getting Started","Other free courses","Linter"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleghnidets%2FOHMySQL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleghnidets%2FOHMySQL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleghnidets%2FOHMySQL/lists"}