{"id":23473322,"url":"https://github.com/scalikejdbc/scalikejdbc-async","last_synced_at":"2025-04-12T03:49:14.372Z","repository":{"id":9702294,"uuid":"11652870","full_name":"scalikejdbc/scalikejdbc-async","owner":"scalikejdbc","description":"ScalikeJDBC Extension: Non-blocking APIs in the JDBC way","archived":false,"fork":false,"pushed_at":"2025-03-20T07:58:52.000Z","size":2303,"stargazers_count":314,"open_issues_count":10,"forks_count":40,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-04-12T03:49:06.849Z","etag":null,"topics":["mysql","postgresql","scala","scalikejdbc"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/scalikejdbc.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-07-25T05:44:05.000Z","updated_at":"2025-03-20T07:58:54.000Z","dependencies_parsed_at":"2023-02-17T05:45:54.933Z","dependency_job_id":"70393e81-fe70-43d9-8a6e-60af46b96758","html_url":"https://github.com/scalikejdbc/scalikejdbc-async","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalikejdbc%2Fscalikejdbc-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalikejdbc%2Fscalikejdbc-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalikejdbc%2Fscalikejdbc-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scalikejdbc%2Fscalikejdbc-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scalikejdbc","download_url":"https://codeload.github.com/scalikejdbc/scalikejdbc-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514211,"owners_count":21116899,"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":["mysql","postgresql","scala","scalikejdbc"],"created_at":"2024-12-24T17:19:55.298Z","updated_at":"2025-04-12T03:49:14.356Z","avatar_url":"https://github.com/scalikejdbc.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ScalikeJDBC-Async\n\n### ScalikeJDBC Extension: Non-blocking APIs in the JDBC way\n\nScalikeJDBC-Async provides non-blocking APIs to talk with PostgreSQL and MySQL in the JDBC way. \n\nThis library is built with [jasync-sql](https://github.com/jasync-sql/jasync-sql).\n\n![ScalikeJDBC Logo](https://scalikejdbc.org/img/logo.png)\n\nScalikeJDBC:\n\nhttps://github.com/scalikejdbc/scalikejdbc\n\nScalikeJDBC is a tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.\n\n\n### Important Notice\n\nScalikeJDBC-Async is still in the beta stage. If you don't have motivation to investigate or fix issues by yourself, we recommend you waiting until stable version release someday.\n\n### Supported RDBMS\n\n- PostgreSQL\n- MySQL\n\n### Dependencies\n\nAdd `scalikejdbc-async` to your dependencies.\n\n```scala\nlibraryDependencies ++= Seq(\n  \"org.scalikejdbc\"       %% \"scalikejdbc-async\" % \"0.19.+\",\n  \"com.github.jasync-sql\" %  \"jasync-postgresql\" % \"2.2.+\", // Add this if you go with PostgreSQL\n  \"com.github.jasync-sql\" %  \"jasync-mysql\"      % \"2.2.+\", // Add this if you go with MySQL / MariaDB\n  \"org.slf4j\"             %  \"slf4j-simple\"      % \"1.7.+\" // Add you preferred slf4j implementation\n)\n```\n\n### Example\n\n- [programmerlist/ExampleSpec.scala](https://github.com/scalikejdbc/scalikejdbc-async/blob/master/core/src/test/scala/programmerlist/ExampleSpec.scala)\n- [programmerlist/Company.scala](https://github.com/scalikejdbc/scalikejdbc-async/blob/master/core/src/test/scala/programmerlist/Company.scala)\n- [programmerlist/Programmer.scala](https://github.com/scalikejdbc/scalikejdbc-async/blob/master/core/src/test/scala/programmerlist/Programmer.scala)\n\n```scala\nimport scalikejdbc._, async._\nimport scala.concurrent._\nimport scala.concurrent.duration._\nimport scala.concurrent.ExecutionContext.Implicits.global\n\n// set up connection pool (that's all you need to do)\nAsyncConnectionPool.singleton(\"jdbc:postgresql://localhost:5432/scalikejdbc\", \"sa\", \"sa\")\n\n// create a new record within a transaction\nval created: Future[Company] = AsyncDB.localTx { implicit tx =\u003e\n  for {\n    company \u003c- Company.create(\"ScalikeJDBC, Inc.\", Some(\"https://scalikejdbc.org/\"))\n    seratch \u003c- Programmer.create(\"seratch\", Some(company.id))\n    gakuzzzz \u003c- Programmer.create(\"gakuzzzz\", Some(company.id))\n    xuwei_k \u003c- Programmer.create(\"xuwei-k\", Some(company.id))\n  } yield company\n}\n\nAwait.result(created, 5.seconds)\n\ncreated.foreach { (newCompany: Company) =\u003e\n\n  // delete a record and rollback\n  val withinTx: Future[Unit] = AsyncDB.localTx { implicit tx =\u003e\n    for {\n      restructuring \u003c- Programmer.findAllBy(sqls.eq(p.companyId, newCompany.id)).map { \n        programmers =\u003e programmers.foreach(_.destroy()) \n      }\n      dissolution \u003c- newCompany.destroy()\n      failure \u003c- sql\"Just joking!\".update.future\n    } yield ()\n  }\n\n  try Await.result(withinTx, 5.seconds)\n  catch { case e: Exception =\u003e log.debug(e.getMessage, e) }\n\n  // rollback expected\n  val company = AsyncDB.withPool { implicit s =\u003e\n    Company.find(newCompany.id)\n  }\n  Await.result(company, 5.seconds)\n  val found: Option[Company]= company.value.get.get\n  found.isDefined should be(true)\n}\n```\n\nTransactional queries should be executed in series. You cannot use `Future.traverse` or `Future.sequence`.\n\n### FAQ\n\n#### Is it production-ready?\n\nScalikeJDBC-Async and [jasync-sql](https://github.com/jasync-sql/jasync-sql) basically works fine. However, to be honest, ScalikeJBDC-Async doesn't have much of a record of production applications.\n\n#### Is it possible to combine scalikejdbc-async with normal scalikejdbc?\n\nYes, it's possible. See [this example](https://github.com/scalikejdbc/scalikejdbc-async/blob/master/core/src/test/scala/sample/PostgreSQLSampleSpec.scala).\n\n#### Why isn't it a part of scalikejdbc project now?\n\nThis library is still in alpha stage. If this library becomes stable enough, it will be merged into the ScalikeJDBC project.\n\n#### How to contribute?\n\nBefore sending pull requests, please install docker and run `sbt +test`\n\n### License\n\nPublished binary files have the following copyright:\n\n```\nCopyright scalikejdbc.org\n\nApache License, Version 2.0\n\nhttp://www.apache.org/licenses/LICENSE-2.0.html\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalikejdbc%2Fscalikejdbc-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscalikejdbc%2Fscalikejdbc-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscalikejdbc%2Fscalikejdbc-async/lists"}