{"id":19428480,"url":"https://github.com/gitbucket/blocking-slick","last_synced_at":"2026-01-11T17:35:31.833Z","repository":{"id":38265280,"uuid":"65343738","full_name":"gitbucket/blocking-slick","owner":"gitbucket","description":"Slick2 compatible blocking API for Slick3","archived":false,"fork":false,"pushed_at":"2025-12-22T03:06:27.000Z","size":215,"stargazers_count":59,"open_issues_count":2,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-12-23T14:48:27.249Z","etag":null,"topics":["database","scala","slick","sql"],"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/gitbucket.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-08-10T02:29:26.000Z","updated_at":"2025-12-22T03:06:31.000Z","dependencies_parsed_at":"2023-10-03T04:33:17.681Z","dependency_job_id":"6a14b197-d8cb-4a32-b2c2-7b911e14ab2f","html_url":"https://github.com/gitbucket/blocking-slick","commit_stats":null,"previous_names":["takezoe/blocking-slick"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/gitbucket/blocking-slick","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fblocking-slick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fblocking-slick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fblocking-slick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fblocking-slick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitbucket","download_url":"https://codeload.github.com/gitbucket/blocking-slick/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fblocking-slick/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28315879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","scala","slick","sql"],"created_at":"2024-11-10T14:15:22.360Z","updated_at":"2026-01-11T17:35:31.816Z","avatar_url":"https://github.com/gitbucket.png","language":"Scala","readme":"blocking-slick [![Scala CI](https://github.com/gitbucket/blocking-slick/actions/workflows/scala.yml/badge.svg)](https://github.com/gitbucket/blocking-slick/actions/workflows/scala.yml)\n==============\n\nProvides Slick2 compatible blocking API for Slick3.\n\nSetup\n-----\n\nAdd following dependency to your `build.sbt`:\n\n```scala\n// for Slick 3.5 (Scala 2 / Scala 3)\nlibraryDependencies += \"com.github.takezoe\" %% \"blocking-slick\" % \"0.0.15-RC2\"\n\n// for Slick 3.4 (Scala 2)\nlibraryDependencies += \"com.github.takezoe\" %% \"blocking-slick\" % \"0.0.14\"\n\n// for Slick 3.3\nlibraryDependencies += \"com.github.takezoe\" %% \"blocking-slick-33\" % \"0.0.13\"\n\n// for Slick 3.2\nlibraryDependencies += \"com.github.takezoe\" %% \"blocking-slick-32\" % \"0.0.11\"\n\n// for Slick 3.1\nlibraryDependencies += \"com.github.takezoe\" %% \"blocking-slick-31\" % \"0.0.7\"\n```\n\nYou can enable blocking API by import the blocking driver as follows:\n\n```scala\nimport com.github.takezoe.slick.blocking.BlockingH2Driver.blockingApi._\n```\n\nSlick2 style blocking API\n----\n\nSee the example of use of blocking API provided by blocking-slick:\n\n```scala\nval db = Database.forURL(\"jdbc:h2:mem:test\")\n\ndb.withSession { implicit session =\u003e\n  // Create tables\n  models.Tables.schema.create\n\n  // Insert\n  Users.insert(UsersRow(1, \"takezoe\"))\n  \n  // Insert returning new id\n  val newID: Long = (Users returning Users.map(_.id)).insert(UsersRow(1, \"takezoe\"))\n\n  // Select\n  val users: Seq[UserRow] = Users.list\n  \n  // Select single record\n  val user: UserRow = Users.filter(_.id === \"takezoe\".bind).first\n  \n  // Select single record with Option\n  val user: Option[UserRow] = Users.filter(_.id === \"takezoe\".bind).firstOption\n\n  // Update\n  Users.filter(t =\u003e t.id === 1.bind).update(UsersRow(1, \"naoki\"))\n  \n  // Delete\n  Users.filter(t =\u003e t.id === 1.bind).delete\n  \n  // Drop tables\n  models.Tables.schema.remove\n}\n```\n\nPlain sql can be executed synchronously as well.\n\n```scala\nval id = 1\nval name = \"takezoe\"\nval insert = sqlu\"INSERT INTO USERS (ID, NAME) VALUES (${id1}, ${name1})\"\ninsert.execute\n```\n\nTransaction is available by using `withTransaction` instead of `withSession`:\n\n```scala\n// Transaction\ndb.withTransaction { implicit session =\u003e\n  ...\n}\n```\n\nDBIO support\n----\n\nblocking-slick also provides a way to run `DBIO` synchronously. It would help to rewrite Slick2 style code to Slick3 style code gradually.\n\n```scala\ndb.withSession { implicit session =\u003e\n  val id1 = 1\n  val id2 = 2\n  val name1 = \"takezoe\"\n  val name2 = \"chibochibo\"\n  val insert1 = sqlu\"INSERT INTO USERS (ID, NAME) VALUES (${id1}, ${name1})\" andThen\n                sqlu\"INSERT INTO USERS (ID, NAME) VALUES (${id2}, ${name2})\"\n  insert1.run\n\n  val query = for {\n    count \u003c- sql\"SELECT COUNT(*) FROM USERS\".as[Int].head\n    max   \u003c- sql\"SELECT MAX(ID) FROM USERS\".as[Int].head\n  } yield (count, max)\n  val (count1, max1) = query.run\n  assert(count1 == 2)\n  assert(max1 == 2)\n}\n```\n\nNote that using `flatMap` and `andThen` requires an `ExecutionContext`, but if you run that code synchronously that value will be ignored.\n\nResources\n----\n\nYou can see actual codes in [the testcase](https://github.com/gitbucket/blocking-slick/blob/master/src/test/scala/com/github/takezoe/slick/blocking/SlickBlockingAPISpec.scala), and also a blocking-slick with Play2 and play-slick example is available at [here](https://github.com/takezoe/blocking-slick-play2).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbucket%2Fblocking-slick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitbucket%2Fblocking-slick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbucket%2Fblocking-slick/lists"}