JDBC wrapper library that is actually slightly usable
Find a file
2025-09-30 20:46:48 -05:00
project initial commit 2025-07-22 23:31:13 -04:00
src doing things with the DSL 2025-09-30 20:37:08 -05:00
.gitignore begone intellij! 2025-07-22 23:45:47 -04:00
build.sbt initial commit 2025-07-22 23:31:13 -04:00
LICENSE_GPL.md initial commit 2025-07-22 23:31:13 -04:00
LICENSE_LGPL.md initial commit 2025-07-22 23:31:13 -04:00
README.md update README with DSL changes 2025-09-30 20:46:48 -05:00

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