All Projects → datadotworld → dw-jdbc

datadotworld / dw-jdbc

Licence: Apache-2.0 license
JDBC driver for data.world

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to dw-jdbc

data.world-r
R library for data.world
Stars: ✭ 59 (+247.06%)
Mutual labels:  open-data, datasets, reference-implementation
data.world-py
Python package for data.world
Stars: ✭ 98 (+476.47%)
Mutual labels:  open-data, datasets, reference-implementation
Transitland Datastore
Transitland's centralized web service API for both querying and editing aggregated transit data from around the world
Stars: ✭ 101 (+494.12%)
Mutual labels:  open-data, datasets
wikdict-gen
Generation of bilingual dictionaries from Wiktionary/dbnary data for the WikDict project
Stars: ✭ 32 (+88.24%)
Mutual labels:  sparql, open-data
Codesearchnet
Datasets, tools, and benchmarks for representation learning of code.
Stars: ✭ 1,378 (+8005.88%)
Mutual labels:  open-data, datasets
CSV2RDF
Streaming, transforming, SPARQL-based CSV to RDF converter. Apache license.
Stars: ✭ 48 (+182.35%)
Mutual labels:  sparql, open-data
Openml R
R package to interface with OpenML
Stars: ✭ 81 (+376.47%)
Mutual labels:  open-data, datasets
git-rdm
A research data management plugin for the Git version control system.
Stars: ✭ 34 (+100%)
Mutual labels:  open-data, datasets
viziquer
Tool for Search in Structured Semantic Data
Stars: ✭ 12 (-29.41%)
Mutual labels:  sparql
website-old
The Frictionless Data website.
Stars: ✭ 31 (+82.35%)
Mutual labels:  open-data
semantic-python-overview
(subjective) overview of projects which are related both to python and semantic technologies (RDF, OWL, Reasoning, ...)
Stars: ✭ 406 (+2288.24%)
Mutual labels:  sparql
datascience
Keeping track of activities around research data
Stars: ✭ 29 (+70.59%)
Mutual labels:  open-data
whyqd
data wrangling simplicity, complete audit transparency, and at speed
Stars: ✭ 16 (-5.88%)
Mutual labels:  open-data
cia
Citizen Intelligence Agency, open-source intelligence (OSINT) project
Stars: ✭ 79 (+364.71%)
Mutual labels:  open-data
Spatio-Temporal-papers
This project is a collection of recent research in areas such as new infrastructure and urban computing, including white papers, academic papers, AI lab and dataset etc.
Stars: ✭ 180 (+958.82%)
Mutual labels:  datasets
rHealthDataGov
R interface to the HealthData.gov Data API
Stars: ✭ 38 (+123.53%)
Mutual labels:  open-data
bumblebee
🚕 A spreadsheet-like data preparation web app that works over Optimus (Pandas, Dask, cuDF, Dask-cuDF, Spark and Vaex)
Stars: ✭ 120 (+605.88%)
Mutual labels:  datasets
adresse.data.gouv.fr
Le site officiel de l'Adresse
Stars: ✭ 139 (+717.65%)
Mutual labels:  open-data
Archived-SANSA-Query
SANSA Query Layer
Stars: ✭ 31 (+82.35%)
Mutual labels:  sparql
motor-defect-detector-python
Predict performance issues with manufacturing equipment motors. Perform local or cloud analytics of the issues found, and then display the data on a user interface to determine when failures might arise.
Stars: ✭ 24 (+41.18%)
Mutual labels:  reference-implementation

dw-jdbc

dw-jdbc is a JDBC driver for connecting to datasets hosted on data.world. It can be used to provide read-only access to any dataset provided by data.world from any JVM language. dw-jdbc supports query access both in dwSQL (data.world's SQL dialect) and in SPARQL 1.1, the native query language for semantic web data sources.

JDBC URLs

JDBC connects to data source based on a provided JDBC url. data.world JDBC urls have the form

jdbc:data:world:[language]:[user id]:[dataset id]

where:

  • [language] is either sql or sparql
  • [user id] is the data.world id of the dataset owner
  • [dataset id] is the data.world id of the dataset

You can extract these ids from the dataset home page url: https://data.world/[user id]/[dataset id].

Sample code (Java 8)

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;


final String QUERY = "select * from HallOfFame where playerID = ? order by yearid, playerID limit 10";
final String URL = "jdbc:data:world:sql:dave:lahman-sabremetrics-dataset";


try (final Connection connection =    // get a connection to the database, which will automatically be closed when done
         DriverManager.getConnection(URL, "<your user name>", "<your API token>");
     final PreparedStatement statement = // get a connection to the database, which will automatically be closed when done
         connection.prepareStatement(QUERY)) {
    statement.setString(1, "alexape01"); //bind a query parameter
    try (final ResultSet resultSet = statement.executeQuery()) { //execute the query
        ResultSetMetaData rsmd = resultSet.getMetaData();  //print out the column headers
        int columnsNumber = rsmd.getColumnCount();
        for (int i = 1; i <= columnsNumber; i++) {
            if (i > 1) System.out.print(",  ");
            System.out.print(rsmd.getColumnName(i));
        }
        System.out.println("");
        while (resultSet.next()) { //loop through the query results
            for (int i = 1; i <= columnsNumber; i++) { //print out the column headers
                if (i > 1) System.out.print(",  ");
                String columnValue = resultSet.getString(i);
                System.out.print(columnValue);
            }
            System.out.println("");

            // Note: when calling ResultSet.getObject() prefer the version that takes an explicit Class argument:
            // Integer n = resultSet.getObject(param, Integer.class);
        }
    }
}

Using dw-jdbc in your project

If using Maven, you can use dw-jdbc by just including the following in your pom.xml file:

<dependency>
    <groupId>world.data</groupId>
    <artifactId>dw-jdbc</artifactId>
    <version>0.4.1</version>
</dependency>

See this link at Maven Central to find the latest version number for the JDBC driver.

For some database tools it's easier to install the jdbc driver if it's a single jar. For this reason we also provide dw-jdbc bundled with all its dependencies under the following:

<dependency>
    <groupId>world.data</groupId>
    <artifactId>dw-jdbc</artifactId>
    <classifier>shaded</classifier>
    <version>0.4.1</version>
</dependency>

Finding your Token

  1. Visit https://data.world
  2. Visit your user settings, and click the advanced tab.
  3. Copy your token.

Features

  • JDBC 4.2

  • The driver only supports read-only queries. It does not support INSERT/UPDATE/DELETE, DDL, or transactions.

  • Queries can be written in SPARQL 1.1 or in the SQL dialect described at https://docs.data.world/tutorials/dwsql/.

  • [SQL-only] Table and column metadata via java.sql.DatabaseMetaData.

  • [SQL-only] Support for positional parameters via java.sql.PreparedStatement.

  • [SPARQL-only] Support for named parameters via java.sql.CallableStatement.

    • For example, CallableStatement.setString("name", "value") will bind the string value to ?name within the query.
  • The DataWorldStatement.setJdbcCompatibilityLevel(JdbcCompatibility) method can be used to adjust how the JDBC driver maps query results to Java objects in java.sql.ResultSetMetaData. This is particularly relevant to SPARQL queries where result types in a column can vary from row to row.

    • JdbcCompatibility.LOW - No assumptions are made about types. ResultSetMetaData.getColumnType() returns java.sql.Types.OTHER and ResultSet.getObject() returns world.data.jdbc.model.Node.

    • JdbcCompatibility.MEDIUM - [SPARQL default] All columns are typed as string. ResultSetMetaData.getColumnType() returns java.sql.Types.NVARCHAR and ResultSet.getObject() returns java.lang.String.

    • JdbcCompatibility.HIGH - [SQL default] Columns are typed based on the underlying data, either using table metadata (SQL) or by inspecting the first row of the response (SPARQL).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].