io.vulpine.lib:sql-import

SQL resource loading

License

License

GroupId

GroupId

io.vulpine.lib
ArtifactId

ArtifactId

sql-import
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

io.vulpine.lib:sql-import
SQL resource loading
Project URL

Project URL

https://github.com/foxcapades/java-sql-import
Project Organization

Project Organization

Foxcapades
Source Code Management

Source Code Management

https://github.com/foxcapades/java-sql-import

Download sql-import

How to add to project

<!-- https://jarcasting.com/artifacts/io.vulpine.lib/sql-import/ -->
<dependency>
    <groupId>io.vulpine.lib</groupId>
    <artifactId>sql-import</artifactId>
    <version>0.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.vulpine.lib/sql-import/
implementation 'io.vulpine.lib:sql-import:0.2.1'
// https://jarcasting.com/artifacts/io.vulpine.lib/sql-import/
implementation ("io.vulpine.lib:sql-import:0.2.1")
'io.vulpine.lib:sql-import:jar:0.2.1'
<dependency org="io.vulpine.lib" name="sql-import" rev="0.2.1">
  <artifact name="sql-import" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.vulpine.lib', module='sql-import', version='0.2.1')
)
libraryDependencies += "io.vulpine.lib" % "sql-import" % "0.2.1"
[io.vulpine.lib/sql-import "0.2.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

sql-import

sql import Codacy code quality License Java Version

SQL resource loading & caching.

Reads from a configurable standardized directory layout organized by query type.

Queries are cached per SqlLoader instance so repeated loads of the same query will only incur the filesystem I/O cost once.

Import functions utilize the java.util.Optional type. In the event that a query does not exist or cannot be loaded, an empty Optional will be returned, otherwise the Optional will contain the SQL text loaded from the specified file.

Examples

Resource directory using default settings
/resource-dir (src/main/resources for Gradle projects)
  └─ /sql
      ├─ /delete
      │   ├─ /comments
      │   │   ├─ by-id.sql
      │   │   └─ by-user.sql
      │   └─ /users
      │       └─ by-id.sql
      ├─ /insert
      │   ├─ /comment.sql
      │   └─ /user.sql
      ├─ /select
      (etc...)

Using the example above loading queries could be accomplished by the following:

Example.java
public void example() {
  var loader      = new SqlLoader(); // (1)
  var delComments = loader.delete("comments.by-user"); // (2)
  var delUsers    = loader.delete("users/by-id"); // (3)
  var insUser     = loader.insert("user");
}
  1. Defaulted SqlLoader instance

  2. Import using dot notation

  3. Import using path notation

Versions

Version
0.2.1
0.2.0