- Scala 100%
| project | ||
| src | ||
| .gitignore | ||
| build.sbt | ||
| LICENSE_GPL.md | ||
| LICENSE_LGPL.md | ||
| README.md | ||
sdbc
sdbc is a wrapper for the Java Database Connectivity (JDBC) API that provides a more tolerable interface for building database queries. It also provides a more flexible way to prepare SQL statements with user input, while preserving security from SQL injection.
Most features are still in progress, the following is an example of ideally what would be implemented.
DSL
sdbc provides a DSL for assembling SQL queries. For example, a SELECT query:
select("a", "bar.b", "bar.c" as "d")
.from("foo")
.innerJoin("bar").onColumn("a")
.where("d" #== 5)
should translate to:
SELECT a, bar.b, bar.c AS d
FROM foo
INNER JOIN bar ON foo.a == bar.a
WHERE d = 5
and an INSERT query:
val toInsert = Map("a" -> 1, "b" -> 5, "c" -> 7)
insert(toInsert)
.into("bar")
should translate to:
INSERT INTO bar(a, b, c) VALUES(1, 5, 7)
Managed Database Schema
You can create your classes with the Schema trait to automatically create tables based on class parameters:
class Foo(a: Int, b: String, c: String)
extends Schema
will make it so you can execute queries such as:
select[Foo]
.from("foo")
.where("a" #== 5)
which would return the type List[Foo]
License
This program is licensed under the GNU Lesser General Public License, version 3.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU Lesser General Public License (and the GNU General Public License) along
with this program. If not, see https://www.gnu.org/licenses/.