{"id":20456373,"url":"https://github.com/alenkacz/postgres-scala","last_synced_at":"2025-10-10T03:32:29.291Z","repository":{"id":71632923,"uuid":"78679770","full_name":"alenkacz/postgres-scala","owner":"alenkacz","description":"Asynchronous library to access PostgreSQL using Scala","archived":false,"fork":false,"pushed_at":"2017-08-19T06:27:07.000Z","size":144,"stargazers_count":5,"open_issues_count":5,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-10T03:32:11.168Z","etag":null,"topics":["postgresql","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/alenkacz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-01-11T21:05:30.000Z","updated_at":"2020-08-21T02:10:01.000Z","dependencies_parsed_at":"2023-05-13T00:30:35.773Z","dependency_job_id":null,"html_url":"https://github.com/alenkacz/postgres-scala","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/alenkacz/postgres-scala","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alenkacz%2Fpostgres-scala","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alenkacz%2Fpostgres-scala/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alenkacz%2Fpostgres-scala/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alenkacz%2Fpostgres-scala/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alenkacz","download_url":"https://codeload.github.com/alenkacz/postgres-scala/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alenkacz%2Fpostgres-scala/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002624,"owners_count":26083425,"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-10T02:00:06.843Z","response_time":62,"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":["postgresql","scala"],"created_at":"2024-11-15T11:22:24.586Z","updated_at":"2025-10-10T03:32:29.287Z","avatar_url":"https://github.com/alenkacz.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# postgres-scala\n---------------------\n\n[![Build Status](https://travis-ci.org/alenkacz/postgres-scala.svg)](https://travis-ci.org/alenkacz/postgres-scala) [ ![Download](https://api.bintray.com/packages/alenkacz/maven/postgres-scala_2.12/images/download.svg) ](https://bintray.com/alenkacz/maven/postgres-scala_2.12/_latestVersion)\n\nAsynchronous postgres client for Scala 2.12. It does not reimplement the wheel because currently it uses [postgresql-async](https://github.com/mauricio/postgresql-async) under the hood. So it is just a nicer API for this library.\n\n## Motivation\nThere are several very good postgresql clients for Scala but in my opinion there is still room for another one for these reasons:\n- [scalike](https://github.com/scalikejdbc/scalikejdbc) (asynchronous implementation is not in production-ready state)\n- [postgresql-async](https://github.com/mauricio/postgresql-async) (the API is too low-level)\n- [slick](https://github.com/slick/slick) (too heavy for plain SQL usage)\n\nSometimes your just want to write plain SQL queries (e.g. for performance reasons) and map them to domain objects by hand. This library enable that with a nice scala API.\n\n## Getting started\nCurrent version of the library can be found on [bintray](https://bintray.com/alenkacz/maven/postgres-scala_2.12/_latestVersion)\n\nSBT\n```scala\nresolvers += Resolver.jcenterRepo\n```\n```scala\n\"cz.alenkacz.db\" %% \"postgres-scala_2.12\" % \"\u003cVERSION_HERE\u003e\"\n```\nGradle\n```groovy\nrepositories {  \n   jcenter()  \n}\n```\n```groovy\ncompile 'cz.alenkacz.db:postgres-scala_2.12:\u003cVERSION_HERE\u003e'\n```\n\n### Example usage\n```scala\npackage cz.alenkacz.db.postgresscala\n\nimport com.typesafe.config.ConfigFactory\nimport cz.alenkacz.db.postgresscala._\n\nimport scala.concurrent.ExecutionContext.Implicits.global\n\nobject Example {\n\tdef main(agrs: Array[String]): Unit = {\n\t\timplicit val connection: Connection = PostgresConnection.fromConfig(ConfigFactory.load())\n\n\t\tval testListValue = List(\"a\", \"b\")\n\t\tsql\"SELECT * FROM table WHERE a IN ($testListValue)\".query(row =\u003e DomainObject(row(0).string(), row(1).int()))\n\t\tsql\"SELECT id FROM table WHERE a IN ($testListValue)\".queryValue[Int]()\n\t\tval testValue = 1\n\t\tsql\"SELECT * FROM table WHERE b=$testValue\".query(row =\u003e DomainObject(row(\"a\").string(), row(\"b\").int()))\n\t\tconnection.inTransaction(c =\u003e {\n          for {\n                 val1 \u003c- sql\"SELECT COUNT(*) FROM abc\".count()(c)\n                 val2 \u003c- sql\"SELECT COUNT(*) FROM withuniquekey\".count()(c)\n            } yield val1.getOrElse(0L) + val2.getOrElse(0L)\n        })\n\t}\n}\n\ncase class DomainObject(testString: String, testInt: Int)\n```\n\n## Convenient builder\nSince [typesafe config](https://github.com/typesafehub/config) is de facto standard configuration library for scala, there is an easy way how to create postgres client directly from config. To do that, you need to have a config similar to this one:\n``` \ndatabase {\n  connectionString = \"jdbc:postgresql://localhost:5432/test_db?user=your_username\u0026password=your_password\"\n\n  maxMessageSize = 16777216 // optional\n  connectTimeout = 5 seconds // optional\n  disconnectTimeout = 5 seconds // optional\n  testTimeout = 5 seconds // optional\n  queryTimeout = 6 seconds // optional\n\n  // optional, do not use pool section if you do not want pooled connection\n  pool {\n    maxConnections = 3\n    idleTime = 5 seconds\n    maxQueueSize = 10\n  }\n}\n```\n\nTo create the connection in the code, all you have to do is call\n```scala\nimport cz.alenkacz.db.postgresscala\nimport import com.typesafe.config.ConfigFactory\n\nval connection = PostgresConnection.fromConfig(ConfigFactory.load().getConfig(\"database\"))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falenkacz%2Fpostgres-scala","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falenkacz%2Fpostgres-scala","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falenkacz%2Fpostgres-scala/lists"}