All Projects → scalikejdbc → Scalikejdbc

scalikejdbc / Scalikejdbc

Licence: other
A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Scalikejdbc

Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+312.2%)
Mutual labels:  jdbc, database, mysql, postgresql
Dbshield
Database firewall written in Go
Stars: ✭ 620 (-45.57%)
Mutual labels:  database, mysql, postgresql
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (-95.52%)
Mutual labels:  database, mysql, postgresql
Laravel Db Snapshots
Quickly dump and load databases
Stars: ✭ 650 (-42.93%)
Mutual labels:  database, mysql, postgresql
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+2231.78%)
Mutual labels:  database, mysql, postgresql
Hibernate Springboot
Collection of best practices for Java persistence performance in Spring Boot applications
Stars: ✭ 589 (-48.29%)
Mutual labels:  jdbc, mysql, postgresql
Dbbench
🏋️ dbbench is a simple database benchmarking tool which supports several databases and own scripts
Stars: ✭ 52 (-95.43%)
Mutual labels:  database, mysql, postgresql
Backup
Easy full stack backup operations on UNIX-like systems.
Stars: ✭ 4,682 (+311.06%)
Mutual labels:  database, mysql, postgresql
Database rewinder
minimalist's tiny and ultra-fast database cleaner
Stars: ✭ 685 (-39.86%)
Mutual labels:  database, mysql, postgresql
Metabase
The simplest, fastest way to get business intelligence and analytics to everyone in your company 😋
Stars: ✭ 26,803 (+2253.2%)
Mutual labels:  database, mysql, postgresql
Db Dumper
Dump the contents of a database
Stars: ✭ 744 (-34.68%)
Mutual labels:  database, mysql, postgresql
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (-52.68%)
Mutual labels:  database, mysql, postgresql
Qb
The database toolkit for go
Stars: ✭ 524 (-53.99%)
Mutual labels:  database, mysql, postgresql
Beekeeper Studio
Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more. Linux, MacOS, and Windows.
Stars: ✭ 8,053 (+607.02%)
Mutual labels:  database, mysql, postgresql
Adminer
Database management in a single PHP file
Stars: ✭ 4,999 (+338.89%)
Mutual labels:  database, mysql, postgresql
Easydb
Easy-to-use PDO wrapper for PHP projects.
Stars: ✭ 624 (-45.22%)
Mutual labels:  database, mysql, postgresql
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (-32.66%)
Mutual labels:  database, mysql, postgresql
Phpmyfaq
phpMyFAQ - Open Source FAQ web application for PHP and MySQL, PostgreSQL and other databases
Stars: ✭ 494 (-56.63%)
Mutual labels:  database, mysql, postgresql
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (-56.28%)
Mutual labels:  database, mysql, postgresql
Blog
Everything about database,business.(Most for PostgreSQL).
Stars: ✭ 6,330 (+455.75%)
Mutual labels:  database, mysql, postgresql

ScalikeJDBC

Just write SQL and get things done!

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

ScalikeJDBC is practical and production-ready. Use this library for your real projects.

http://scalikejdbc.org/

Maven Central Stargazers over time

Gitter Chat for Casual Q&A

  • English: Gitter
  • 日本語 (Japanese): Gitter

Getting Started

Just add ScalikeJDBC, a JDBC driver, and an slf4j implementation to your sbt build settings:

libraryDependencies ++= Seq(
  "org.scalikejdbc" %% "scalikejdbc"        % "3.5.+",
  "com.h2database"  %  "h2"                 % "1.4.+",
  "ch.qos.logback"  %  "logback-classic"    % "1.2.+"
)

If you're a Play2 user, take a look at play-support project, too:

https://github.com/scalikejdbc/scalikejdbc-play-support

First example

After adding the above dependencies to your build.sbt, run sbt console and execute the following code:

import scalikejdbc._

// initialize JDBC driver & connection pool
Class.forName("org.h2.Driver")
ConnectionPool.singleton("jdbc:h2:mem:hello", "user", "pass")

// ad-hoc session provider on the REPL
implicit val session = AutoSession

// table creation, you can run DDL by using #execute as same as JDBC
sql"""
create table members (
  id serial not null primary key,
  name varchar(64),
  created_at timestamp not null
)
""".execute.apply()

// insert initial data
Seq("Alice", "Bob", "Chris") foreach { name =>
  sql"insert into members (name, created_at) values (${name}, current_timestamp)".update.apply()
}

// for now, retrieves all data as Map value
val entities: List[Map[String, Any]] = sql"select * from members".map(_.toMap).list.apply()

// defines entity object and extractor
import java.time._
case class Member(id: Long, name: Option[String], createdAt: ZonedDateTime)
object Member extends SQLSyntaxSupport[Member] {
  override val tableName = "members"
  def apply(rs: WrappedResultSet) = new Member(
    rs.long("id"), rs.stringOpt("name"), rs.zonedDateTime("created_at"))
}

// find all members
val members: List[Member] = sql"select * from members".map(rs => Member(rs)).list.apply()

// use paste mode (:paste) on the Scala REPL
val m = Member.syntax("m")
val name = "Alice"
val alice: Option[Member] = withSQL {
  select.from(Member as m).where.eq(m.name, name)
}.map(rs => Member(rs)).single.apply()

How did it go? If you'd like to know more details or see more practical examples, see the full documentation at:

http://scalikejdbc.org/

License

Published source code and 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].