class2sql


License

License

GroupId

GroupId

com.github.piotr-kalanski
ArtifactId

ArtifactId

class2sql_2.11
Last Version

Last Version

0.1.6
Release Date

Release Date

Type

Type

jar
Description

Description

class2sql
class2sql
Project URL

Project URL

https://github.com/piotr-kalanski/class2sql
Project Organization

Project Organization

com.github.piotr-kalanski
Source Code Management

Source Code Management

https://github.com/piotr-kalanski/class2sql

Download class2sql_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.piotr-kalanski/class2sql_2.11/ -->
<dependency>
    <groupId>com.github.piotr-kalanski</groupId>
    <artifactId>class2sql_2.11</artifactId>
    <version>0.1.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.piotr-kalanski/class2sql_2.11/
implementation 'com.github.piotr-kalanski:class2sql_2.11:0.1.6'
// https://jarcasting.com/artifacts/com.github.piotr-kalanski/class2sql_2.11/
implementation ("com.github.piotr-kalanski:class2sql_2.11:0.1.6")
'com.github.piotr-kalanski:class2sql_2.11:jar:0.1.6'
<dependency org="com.github.piotr-kalanski" name="class2sql_2.11" rev="0.1.6">
  <artifact name="class2sql_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.piotr-kalanski', module='class2sql_2.11', version='0.1.6')
)
libraryDependencies += "com.github.piotr-kalanski" % "class2sql_2.11" % "0.1.6"
[com.github.piotr-kalanski/class2sql_2.11 "0.1.6"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.8
com.chuusai : shapeless_2.11 jar 2.3.2
com.github.piotr-kalanski : csv2class_2.11 jar 0.3.3

test (3)

Group / Artifact Type Version
junit : junit jar 4.10
org.scalatest : scalatest_2.11 jar 2.2.6
com.h2database : h2 jar 1.4.195

Project Modules

There are no modules declared in this project.

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")

Versions

Version
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0