All Projects → chop-dbhi → sql-agent

chop-dbhi / sql-agent

Licence: BSD-2-Clause license
HTTP interface for executing ad-hoc SQL queries.

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to sql-agent

oracle-jdk-portable
🚀 Oracle JDK portable for Windows
Stars: ✭ 24 (-72.41%)
Mutual labels:  oracle
ares
Completely decentralized oracle protocol
Stars: ✭ 51 (-41.38%)
Mutual labels:  oracle
smart-contracts
On-chain system contracts and examples
Stars: ✭ 76 (-12.64%)
Mutual labels:  oracle
metadata
oracle,mysql,sql server 元数据管理表生成
Stars: ✭ 45 (-48.28%)
Mutual labels:  oracle
witnet-solidity-bridge
Witnet Bridge for EVM-compatible blockchains
Stars: ✭ 46 (-47.13%)
Mutual labels:  oracle
vagrant
Vagrant Builds
Stars: ✭ 154 (+77.01%)
Mutual labels:  oracle
apex-plugin-templates
Templates for Oracle APEX Plug-ins
Stars: ✭ 27 (-68.97%)
Mutual labels:  oracle
elcarro-oracle-operator
El Carro is a new project that offers a way to run Oracle databases in Kubernetes as a portable, open source, community driven, no vendor lock-in container orchestration system. El Carro provides a powerful declarative API for comprehensive and consistent configuration and deployment as well as for real-time operations and monitoring.
Stars: ✭ 204 (+134.48%)
Mutual labels:  oracle
exodus
Migration tools for Tabular Data to Oracle JSON/Tabular Data
Stars: ✭ 19 (-78.16%)
Mutual labels:  oracle
Oracle.jl
Oracle Database driver for the Julia language.
Stars: ✭ 32 (-63.22%)
Mutual labels:  oracle
oracle-single-install
让Oracle数据库安装变得简单化,支持单实例和CDB容器快速安装,只需简单配置即可
Stars: ✭ 37 (-57.47%)
Mutual labels:  oracle
weblogic honeypot
WebLogic Honeypot is a low interaction honeypot to detect CVE-2017-10271 in the Oracle WebLogic Server component of Oracle Fusion Middleware. This is a Remote Code Execution vulnerability.
Stars: ✭ 30 (-65.52%)
Mutual labels:  oracle
laravel-adminer
Adminer database management tool for your Laravel application.
Stars: ✭ 45 (-48.28%)
Mutual labels:  oracle
DataX-src
DataX 是异构数据广泛使用的离线数据同步工具/平台,实现包括 MySQL、Oracle、SqlServer、Postgre、HDFS、Hive、ADS、HBase、OTS、ODPS 等各种异构数据源之间高效的数据同步功能。
Stars: ✭ 21 (-75.86%)
Mutual labels:  oracle
aco-oracle java
Puppet module to install Oracle Java on Linux systems
Stars: ✭ 13 (-85.06%)
Mutual labels:  oracle
rust-oracle
Oracle driver for Rust
Stars: ✭ 139 (+59.77%)
Mutual labels:  oracle
method5
Remote execution for Oracle SQL, PL/SQL, and shell scripts, built entirely inside Oracle. Method5 lets you easily run commands quickly and securely on hundreds of databases.
Stars: ✭ 19 (-78.16%)
Mutual labels:  oracle
sqle
SQLE is a SQL audit platform | SQLE 是一个支持多场景,原生支持 MySQL 审核且数据库类型可扩展的 SQL 审核工具
Stars: ✭ 731 (+740.23%)
Mutual labels:  oracle
uclapi
An API for University College London, created for and by students!
Stars: ✭ 41 (-52.87%)
Mutual labels:  oracle
nosql-go-sdk
SDK for Go for Oracle NoSQL Database
Stars: ✭ 26 (-70.11%)
Mutual labels:  oracle

SQL Agent

GoDoc

SQL Agent is an HTTP service for executing ad-hoc queries on remote databases. The motivation for this service is to be part of a data monitoring process or system in which the query results will be evaluated against previous snapshots of the results.

The supported databases are:

  • PostgreSQL
  • MySQL, MariaDB
  • Oracle
  • Microsoft SQL Server
  • SQLite
  • Snowflake
  • Presto

In addition to the service, this repo also defines a sqlagent package for using in other Go programs.

Install

At the moment, it is recommended to run the service using Docker because there are no pre-built binaries yet.

docker run -d -p 5000:5000 dbhi/sql-agent

Usage

To execute a query, simply send a POST request with a payload containing the driver name of the database, connection information to with, and the SQL statement with optional parameters. The service will connect to the database, execute the query and return the results as a JSON-encoded array of maps (see details below).

Request

POST

Headers:

  • 'Accept' - required
    • application/json
    • application/x-ldjson
    • text/csv
{
    "driver": "postgres",
    "connection": {
        "host": "localhost",
        "user": "postgres"
    },
    "sql": "SELECT name FROM users WHERE zipcode = :zipcode",
    "params": {
        "zipcode": 18019
    }
}

Response

[
    {
        "name": "George"
    },
    ...
]

Connection Options

The core option names are standardized for ease of use.

  • host - The host of the database.
  • port - The port of the database.
  • user - The user to connect with.
  • password - The password to authenticate with.
  • database - The name of the database to connect to. For SQLite, this will be a filesystem path. For Oracle, this would be the SID.

Other options that are supplied are passed query options if they are known, otherwise they are they ignored.

Alternatively, the dsn parameter can be specified which will used directly when opening a connection.

Ping Connection

To validate the connection, send a POST with the ?ping query parameter present and it will test the connection only.

Details

  • Only SELECT statements are supported.
  • Statements using parameters must use the :param syntax and must have a corresponding entry in the params map.

Constraints

  • Columns must be uniquely named, otherwise the conversion into a map will include only one of the values.

Library

The SQL Agent library does not include any drivers by default. To add them include them like so:

package main

import (
	_ "github.com/alexbrainman/odbc"
	_ "github.com/denisenkom/go-mssqldb"
	_ "github.com/go-sql-driver/mysql"
	_ "github.com/lib/pq"
	_ "github.com/mattn/go-oci8"
	_ "github.com/mattn/go-sqlite3"
)

func main() {
    //...
}

Help

Install Oracle client libraries

General

In order to install the go-oci8 driver, you must install Oracle's client libraries.

Download the instantclient-basic and instantclient-sdk package from Oracle's website and uncompress to the same directory. Make sure that you selected the platform and architecture.

The installations instructions are listed at the bottom of the page with the download links.

Install pkg-config.

Create oci8.pc file in your $PKG_CONFIG_PATH (such as /usr/local/lib/pkgconfig) and add the below contents:

prefix=/usr/local/lib/instantclient_11_2
libdir=${prefix}
includedir=${prefix}/sdk/include/

Name: OCI
Description: Oracle database engine
Version: 11.2
Libs: -L${libdir} -lclntsh
Libs.private:
Cflags: -I${includedir}

Change the prefix to path to location of the Oracle libraries.

OS X specific Help

Assuming the instantclient_11_2 folder is located in /usr/loca/lib, link the following files:

ln /usr/local/lib/instantclient_11_2/libclntsh.dylib /usr/local/lib/libclntsh.dylib
ln /usr/local/lib/instantclient_11_2/libocci.dylib.* /usr/local/lib/libocci.dylib.*
ln /usr/local/lib/instantclient_11_2/libociei.dylib /usr/local/lib/libociei.dylib
ln /usr/local/lib/instantclient_11_2/libnnz11.dylib /usr/local/lib/libnnz11.dylib

Install pkg-config via Homebrew, brew install pkg-config.

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