Skip to content

SQL insert statements generator based on Scala case class.

License

Notifications You must be signed in to change notification settings

piotr-kalanski/class2sql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

class2sql

SQL insert and select statements generator based on Scala case class.

Build Status codecov.io Stories in Ready License

Table of contents

Goals

  • Provide simple tool for generating SQL inserts based on Scala case classes
  • Provide easy API to query JDBC table and map result to Scala case class

Getting started

Include dependencies

"com.github.piotr-kalanski" % "class2sql_2.11" % "0.1.0"

or

<dependency>
    <groupId>com.github.piotr-kalanski</groupId>
    <artifactId>class2sql_2.11</artifactId>
    <version>0.1.0</version>
</dependency>

Examples

Generate inserts

import com.datawizards.class2jdbc._

case class Person(name: String, age: Int)

val data = Seq(Person("p1", 1), Person("p2", 2))
generateInserts(data)
INSERT INTO Person(name,age) VALUES('p1',1)
INSERT INTO Person(name,age) VALUES('p2',2)

Select from table

import com.datawizards.jdbc2class._

case class Person(name: String, age: Int)

val connectionString = "jdbc:h2:mem:test"
val connection = DriverManager.getConnection(connectionString, "", "")
selectTable[Person](connection, "people")

About

SQL insert statements generator based on Scala case class.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages