{"id":15187522,"url":"https://github.com/bermudadigitalstudio/rope","last_synced_at":"2025-10-02T01:31:35.362Z","repository":{"id":63905340,"uuid":"78554000","full_name":"bermudadigitalstudio/Rope","owner":"bermudadigitalstudio","description":"Convenient, easy-to-use PostgreSQL for server-side Swift 3","archived":true,"fork":false,"pushed_at":"2019-05-19T15:42:37.000Z","size":116,"stargazers_count":19,"open_issues_count":10,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-09-14T21:34:29.321Z","etag":null,"topics":["database","postgresql","server-side-swift","swift","swift-framework"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bermudadigitalstudio.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":"2017-01-10T16:52:04.000Z","updated_at":"2024-08-12T19:27:04.000Z","dependencies_parsed_at":"2022-11-28T19:42:19.424Z","dependency_job_id":null,"html_url":"https://github.com/bermudadigitalstudio/Rope","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/bermudadigitalstudio/Rope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bermudadigitalstudio%2FRope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bermudadigitalstudio%2FRope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bermudadigitalstudio%2FRope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bermudadigitalstudio%2FRope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bermudadigitalstudio","download_url":"https://codeload.github.com/bermudadigitalstudio/Rope/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bermudadigitalstudio%2FRope/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277942684,"owners_count":25903112,"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-01T02:00:09.286Z","response_time":88,"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","postgresql","server-side-swift","swift","swift-framework"],"created_at":"2024-09-27T18:23:43.511Z","updated_at":"2025-10-02T01:31:35.123Z","avatar_url":"https://github.com/bermudadigitalstudio.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rope\n\nRope provides a convenient, easy-to-use, type-safe access to `PostgreSQL` for server-side Swift 3.   \nIt uses the thread-safe, highly performant `libpq` library.\n\n[![Language Swift 3](https://img.shields.io/badge/Language-Swift%203-orange.svg)](https://swift.org) ![Platforms](https://img.shields.io/badge/Platforms-Docker%20%7C%20Linux%20%7C%20macOS-blue.svg) [![CircleCI](https://circleci.com/gh/bermudadigitalstudio/Rope/tree/master.svg?style=shield)](https://circleci.com/gh/bermudadigitalstudio/Rope)\n\n\u003cbr\u003e\n\n## How to Use\n\nRope is so simple, you just need to learn 3 methods:\n- `connect()` to create a connection\n- `query()` to run a query\n- `rows()` to turn a query result into a two-dimensional array\n\n\n```swift\n\n// credential struct as helper\nlet creds = RopeCredentials(host: \"localhost\", port: 5432,  dbName: \"mydb\",\n                            user: \"foo\", password: \"bar\")\n\n// establish connection using the struct, returns nil on error\nguard let db = try? Rope.connect(credentials: creds) else {\n\tprint(\"Could not connect to Postgres\")\n\treturn\n}\n\n// run INSERT query, it returns nil on a syntax or connection error\n// the insert is SQL-injection safe due to the use of dollar params!\nlet text = \"Hello World\"\nguard let _ = try? db.query(\"INSERT INTO my_table (my_text) VALUES($1)')\", params: [text]) else {\n\tprint(\"Could not insert \\(text) into database\");\n\treturn\n}\n\n// run SELECT query, it returns nil on a syntax or connection error\nguard let res = try? db.query(\"SELECT id, my_text FROM my_table\") else {\n\tprint(\"Could not fetch id \u0026 my_text from database\")\n\treturn\n}\n\n// execute statements with params (SQL-injection safe)  \nguard let res = try? db.query(\"SELECT * FROM my_table WHERE my_text=$1\", params: [\"Hello World\"]) else {\n    print(\"Could not fetch id \u0026 my_text from database\")\n    return\n}\n\n// handle errors with a do/catch \ndo {\n    let res = try db.query(\"SELECT id, my_text FROM my_table\")\n} catch {\n    // Error handling\n}\n\n// turn result into 2-dimensional array\nif let rows = res?.rows() {\n    for row in rows {\n        let id = row[\"id\"] as? Int\n        let myText = row[\"my_text\"] as? String\n    }\n}\n```\n\n\u003cbr\u003e\n\n## Postgres Types to Swift Conversion\n\n* `serial`, `bigserial`, `smallint`, `integer`, and `bigint` are returned as `Int`\n* `real` and `double` precision are returned as `Float`\n* `char`, `varchar`, and `text` are returned as `String`\n* `json` is converted to a `Dictionary` of `[String: Any?]`\n* the `boolean` type is returned as `Bool`\n* `date`, `timestamp` are returned as `Date`\n\n\n\u003cbr\u003e\n\n## Running Unit Tests\n\nRope’s unit tests require a running Postgres 9.x database and you can either provide the database credentials via environment variables, or via CLI arguments or use the built-in default values.\n\n#### Using Defaults\n\nAll tests run without any additional configuration if your database has the following setup:\n\n* `host: \"localhost\"`\n* `port: 5432`\n* `database name: \"rope\"`\n* `user: \"postgres\"`\n* `password: \"\"`\n\n#### Using Environment Variables\n\nYou can easily provide the database credentials via environment variables.\nPlease see the `RopeTestCredentials.swift` file. Please also see the unit tests about how to use RopeCredentials to establish a connection.\n\nFor environment variables **in Xcode**, please enter the following info via `Edit Scheme` \u003e `Arguements` using `Environment Variables` or `Arguments Passend On Launch`:\n\n* `DATABASE_HOST`\n* `DATABASE_PORT`\n* `DATABASE_NAME`\n* `DATABASE_USER`\n* `DATABASE_PASSWORD`\n\n\n#### Using CLI Arguments\n\n```\nswift build DATABASE_HOST=mydatabase_host DATABASE_PORT=mydatabase_port DATABASE_NAME=mydatabase_dbname DATABASE_USER=mydatabase_user DATABASE_PASSWORD=mydatabase_very_secure_password\n```\n\nTo run tests simple type `swift test` in your CLI.\n\n\u003cbr\u003e\n\n## Source Code Linting\n\nThe source code is formatted using [SwiftLint](https://github.com/realm/SwiftLint) and all commits \u0026 PRs need to be without any SwiftLint warnings or errors.\n\n\u003cbr\u003e\n\n## Contributing\n\nRope is maintained by Thomas Catterall ([@swizzlr](https://github.com/swizzlr)), Johannes Erhardt ([@johanneserhardt](https://github.com/johanneserhardt)), Sebastian Kreutzberger ([@skreutzberger](https://github.com/skreutzberger)).\n\nContributions are more than welcomed. You can either work on existing Github issues or discuss with us your ideas in a new Github issue. Thanks 🙌\n\n\u003cbr\u003e\u003cbr\u003e\n\n## License\n\nRope is released under the [Apache 2.0 License](https://github.com/bermudadigitalstudio/rope/blob/master/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbermudadigitalstudio%2Frope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbermudadigitalstudio%2Frope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbermudadigitalstudio%2Frope/lists"}