All Projects β†’ scalikejdbc β†’ Scalikejdbc Async

scalikejdbc / Scalikejdbc Async

ScalikeJDBC Extension: Non-blocking APIs in the JDBC way

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Scalikejdbc Async

Swifql
πŸ’Ž A Swift DSL for type-safe, extensible, and transformable SQL queries.
Stars: ✭ 250 (-16.67%)
Mutual labels:  mysql, postgresql
Xo
Command line tool to generate idiomatic Go code for SQL databases supporting PostgreSQL, MySQL, SQLite, Oracle, and Microsoft SQL Server
Stars: ✭ 2,974 (+891.33%)
Mutual labels:  mysql, postgresql
Php Crud Api
Single file PHP script that adds a REST API to a SQL database
Stars: ✭ 2,904 (+868%)
Mutual labels:  mysql, postgresql
Node Orm2
Object Relational Mapping
Stars: ✭ 3,063 (+921%)
Mutual labels:  mysql, postgresql
Dbq
Zero boilerplate database operations for Go
Stars: ✭ 273 (-9%)
Mutual labels:  mysql, postgresql
Sql Lint
An SQL linter
Stars: ✭ 243 (-19%)
Mutual labels:  mysql, postgresql
Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+1191.33%)
Mutual labels:  mysql, postgresql
Gorm Bulk Insert
implement BulkInsert using gorm, just pass a Slice of Struct. Simple and compatible.
Stars: ✭ 241 (-19.67%)
Mutual labels:  mysql, postgresql
Pg chameleon
MySQL to PostgreSQL replica system
Stars: ✭ 274 (-8.67%)
Mutual labels:  mysql, postgresql
Entityframework.exceptions
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
Stars: ✭ 266 (-11.33%)
Mutual labels:  mysql, postgresql
Typescript Express Starter
πŸš€ TypeScript Express Starter
Stars: ✭ 238 (-20.67%)
Mutual labels:  mysql, postgresql
Sqlc
Generate type-safe code from SQL
Stars: ✭ 4,564 (+1421.33%)
Mutual labels:  mysql, postgresql
Aerich
A database migrations tool for TortoiseORM, ready to production.
Stars: ✭ 240 (-20%)
Mutual labels:  mysql, postgresql
E Commerce Db
Database schema for e-commerce (webstores) sites.
Stars: ✭ 245 (-18.33%)
Mutual labels:  mysql, postgresql
Sqlfiddle3
New version based on vert.x and docker
Stars: ✭ 242 (-19.33%)
Mutual labels:  mysql, postgresql
Freesql
πŸ¦„ .NET orm, Mysql orm, Postgresql orm, SqlServer orm, Oracle orm, Sqlite orm, Firebird orm, θΎΎζ’¦ orm, 人倧金仓 orm, η₯žι€š orm, 翰高 orm, ε—ε€§ι€šη”¨ orm, Click house orm, MsAccess orm.
Stars: ✭ 3,077 (+925.67%)
Mutual labels:  mysql, postgresql
Graphqlize
A Clojure & JVM library for developing GraphQL API instantly from Postgres and MySQL databases
Stars: ✭ 240 (-20%)
Mutual labels:  mysql, postgresql
Redaxscript
A modern, ultra lightweight and rocket fast Content Management System
Stars: ✭ 241 (-19.67%)
Mutual labels:  mysql, postgresql
Junixsocket
Unix Domain Sockets in Java (AF_UNIX)
Stars: ✭ 265 (-11.67%)
Mutual labels:  mysql, postgresql
Jsqlparser
JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes. The generated hierarchy can be navigated using the Visitor Pattern
Stars: ✭ 3,405 (+1035%)
Mutual labels:  mysql, postgresql

ScalikeJDBC-Async

ScalikeJDBC Extension: Non-blocking APIs in the JDBC way

ScalikeJDBC-Async provides non-blocking APIs to talk with PostgreSQL and MySQL in the JDBC way.

This library is built with jasync-sql.

ScalikeJDBC Logo

ScalikeJDBC:

https://github.com/scalikejdbc/scalikejdbc

ScalikeJDBC is a tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.

Important Notice

ScalikeJDBC-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.

Supported RDBMS

  • PostgreSQL
  • MySQL

Dependencies

Add scalikejdbc-async to your dependencies.

libraryDependencies ++= Seq(
  "org.scalikejdbc"       %% "scalikejdbc-async" % "0.14.+",
  "com.github.jasync-sql" %  "jasync-postgresql" % "1.1.+",
  "com.github.jasync-sql" %  "jasync-mysql"      % "1.1.+",
  "org.slf4j"             %  "slf4j-simple"      % "1.7.+" // slf4j implementation
)

Example

import scalikejdbc._, async._
import scala.concurrent._, duration._, ExecutionContext.Implicits.global

// set up connection pool (that's all you need to do)
AsyncConnectionPool.singleton("jdbc:postgresql://localhost:5432/scalikejdbc", "sa", "sa")

// create a new record within a transaction
val created: Future[Company] = AsyncDB.localTx { implicit tx =>
  for {
    company <- Company.create("ScalikeJDBC, Inc.", Some("http://scalikejdbc.org/"))
    seratch <- Programmer.create("seratch", Some(company.id))
    gakuzzzz <- Programmer.create("gakuzzzz", Some(company.id))
    xuwei_k <- Programmer.create("xuwei-k", Some(company.id))
  } yield company
}

Await.result(created, 5.seconds)

created.foreach { (newCompany: Company) =>

  // delete a record and rollback
  val withinTx: Future[Unit] = AsyncDB.localTx { implicit tx =>
    for {
      restructuring <- Programmer.findAllBy(sqls.eq(p.companyId, newCompany.id)).map { 
        programmers => programmers.foreach(_.destroy()) 
      }
      dissolution <- newCompany.destroy()
      failure <- sql"Just joking!".update.future
    } yield ()
  }

  try Await.result(withinTx, 5.seconds)
  catch { case e: Exception => log.debug(e.getMessage, e) }

  // rollback expected
  val company = AsyncDB.withPool { implicit s =>
    Company.find(newCompany.id)
  }
  Await.result(company, 5.seconds)
  val found: Option[Company]= company.value.get.get
  found.isDefined should be(true)
}

Transactional queries should be executed in series. You cannot use Future.traverse or Future.sequence.

FAQ

Is it production-ready?

ScalikeJDBC-Async and jasync-sql basically works fine. However, to be honest, ScalikeJBDC-Async doesn't have much of a record of production applications.

Is it possible to combine scalikejdbc-async with normal scalikejdbc?

Yes, it's possible. See this example.

Why isn't it a part of scalikejdbc project now?

This library is still in alpha stage. If this library becomes stable enough, it will be merged into the ScalikeJDBC project.

How to contribute?

Before sending pull requests, please install docker and run sbt +test

License

Published binary files have the following copyright:

Copyright scalikejdbc.org

Apache License, Version 2.0

http://www.apache.org/licenses/LICENSE-2.0.html
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].