Database Connector

A utility to access and execute queries on databases

License

License

GroupId

GroupId

dev.spiti.utilities
ArtifactId

ArtifactId

db-connector
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Database Connector
A utility to access and execute queries on databases
Project URL

Project URL

https://github.com/spiti-dev/db-connector
Source Code Management

Source Code Management

https://github.com/spiti-dev/db-connector

Download db-connector

How to add to project

<!-- https://jarcasting.com/artifacts/dev.spiti.utilities/db-connector/ -->
<dependency>
    <groupId>dev.spiti.utilities</groupId>
    <artifactId>db-connector</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/dev.spiti.utilities/db-connector/
implementation 'dev.spiti.utilities:db-connector:1.0.0'
// https://jarcasting.com/artifacts/dev.spiti.utilities/db-connector/
implementation ("dev.spiti.utilities:db-connector:1.0.0")
'dev.spiti.utilities:db-connector:jar:1.0.0'
<dependency org="dev.spiti.utilities" name="db-connector" rev="1.0.0">
  <artifact name="db-connector" type="jar" />
</dependency>
@Grapes(
@Grab(group='dev.spiti.utilities', module='db-connector', version='1.0.0')
)
libraryDependencies += "dev.spiti.utilities" % "db-connector" % "1.0.0"
[dev.spiti.utilities/db-connector "1.0.0"]

Dependencies

runtime (2)

Group / Artifact Type Version
org.neo4j.driver : neo4j-java-driver jar 2.0.0-alpha01
com.datastax.cassandra : cassandra-driver-core jar 3.3.0

Project Modules

There are no modules declared in this project.

DB-Connector : Simple way of dealing with databases

Contents

Key Features

  • Reads data from databases (Currently supports Cassandra and Neo4J)
  • Executes queries and converts result set to List<> of Map<String, Object>
  • Read data as List when only one column is being read

Usages

  • Integrate into automation frameworks for data validation
  • Connect with database and run SELECT queries
  • Easy to use data in validations while dealing just with List and Map objects

Limitations

  • Currently supports CASSANDRA AND GRAPH DATABASES ONLY
  • Currently supports to execute retrieve queries only. Add/Update/Delete support to follow.

Examples

CASSANDRA

Create connection and session

Connector dbConnector = new Cassandra(contactPoints,keyspace, username, password);
  • Creates a connection to specified keyspace
  • Session is available on dbConnector object to execute queries

Read from CASSANDRA

For a query like SELECT * FROM <TableName>

List<String> args = new ArrayList<>();
List<Map<String, Object>> data = dbConnector.getData(statement, args);
  • Passes an empty args list to library and returns each row as a map
  • For queries that has filtering conditions, add variables in same sequence as query to the args list

For a query like SELECT <ColumnName> from <TableName>

List<Map<String, Object>> data = dbConnector.getKey(statement, args);
  • Returns the values from the queried column in a list, each value is read as a String

GRAPH

Create connection and session

Connector dbConnector = new Graph(url,username,password);
  • Creates a connection to specified database box in the url. Incase of proxy, connection is made to master
  • Session is available on dbConnector object to execute queries

Read from GRAPH

Versions

Version
1.0.0