Skip to content

redis-field-engineering/redis-sql-odbc-dist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis SQL ODBC

Redis SQL ODBC is a SQL interface for Redis Stack, Redis Cloud, and Redis Enterprise.


Redis SQL ODBC lets you easily integrate Redis with visualization frameworks and BI platforms (e.g., Power BI) and with systems that support the ODBC standard.

Query support includes SELECT statements across secondary indexes covering Redis hashes and JSON objects. You can run filters (full text search, exact text matching, numeric ranges), apply functions (arithmetic, timestamp parsing, string formatting, calculate geodistances), reduce and summarize data (averages, summations, min, max, etc.), group data, order it, and more.

ODBC is a standardized way for clients to communicate with databases. Previous Redis ODBC connectors have been implemented using Redis keyspace scans, which are inefficient. This Redis ODBC connector provides fast queries by levereging the secondary indexing that comes with Redis Stack.

Background

Redis is an in-memory data store designed to serve data with the fastest possible response times. Redis is frequently used for caching OLTP-style application queries and as a serving layer in data pipeline architectures (e.g., lambda architectures, online feature stores, etc.). Redis Stack is an extension to Redis that, among other things, lets you index your data on secondary attributes and then efficiently query it using a custom query language.

We built Redis SQL ODBC to let you query Redis using SQL through ODBC. For example, Redis SQL ODBC lets you read data for business intelligence tools such as Power BI.

Using Redis SQL ODBC, PowerBI, and Redis Stack to build a dashboard for UFO sightings in Florida:

Redis SQL ODBC

Requirements

Redis SQL ODBC requires a Redis Deployment that includes RediSearch.

Redis deployments that bundle RediSearch include:

  • Redis Cloud: Fully-managed, enterprise-grade Redis deployed on AWS, Azure, or GCP.

  • Redis Enterprise: Enterprise-grade Redis for on-premises and private cloud deployments.

  • Redis Stack: Redis distribution that includes RediSearch, RedisJSON, RedisGraph, RedisTimeSeries, and RedisBloom.

Quick Start

This repo includes a demo to get you started. To run the demo, you’ll need:

  • Docker (with Linux Containers if using Windows).

To start the demo, run the following commands:

  1. docker-compose -f demo/docker-compose.yaml build

  2. docker-compose -f demo/docker-compose.yaml up -d

  3. docker exec -it odbc isql -k "DSN=Redis;host=redis;"

Installation

To install Redis SQL ODBC, you need to:

  1. Install the driver itself.

  2. Configure the driver’s data source.

To install the driver, first download the installer.

Download the installer

Fetch the installer zipfile from the Redis SQL ODBC release page. There you’ll find a file called redis-sql-odbc-installers-<VERSION>.zip.

Download and unzip the file.

Install on Linux

Run /bin/bash redis_odbc-<VERSION>-Linux.sh --prefix /usr/local/lib.

This will install the driver in /usr/local/lib.

Install on macOS

Open the file redis-sql-odbc-<VERSION>.pkg, and follow the steps to install the package.

This process will install the driver in /usr/local/lib/redis-sql-odbc.

Install on Windows 10+

Install the Microsoft Visual C++ Redistributable package package for VS 2015-2022. These system libraries are required for the driver to work.

Run the redis-odbc-amd64.msi file, and following steps in the installation wizard.

This will install the binaries at C:\Program Files\redis.

Configure Redis Data Source

Once you’ve installed the Redis SQL ODBC driver, you’ll need to configure a Redis data source using an ODBC Driver Manager.

The ODBC Driver Manager you use may vary, depending in part on your operating system.

For Windows users, we provide instructions for selecting a data source directly from Powershell or using the ODBC Data Source Administrator.

For Linux and macOS users, we show how to select a data source using the unixODBC driver manager.

Windows

Using Powershell

If you want to configure your Redis data source from PowerShell, run the Add-OdbcDsn cmdlet:

Add-OdbcDSN -Name "Redis" -DriverName "Redis" -Platform "64-bit" -DsnType "User" -SetPropertyValue @("host=localhost", "port=6379", "username=default", "password=yourpassword")

Naturally, you should provide the host, port, and username your Redis deployment.

Using the Data Source Admin GUI

To configure your Redis data source using the Windows Data Source Admin GUI:

  1. Run the ODBC Data Source Administrator 64-bit.

  2. Under the User DSN or System DSN tab, click Add.

ODBC DSN Tabs
  1. Select the Redis driver as your driver.

  2. Click Finish.

Create Redis DSN
  1. Provide your Redis connection details in the form that appears.

  2. Click OK

Finish DSN Configuration

Linux and macOS

To configure your data source on Linux and macOS, you can unixODBC and then configure your Redis settings in two .ini configuration files.

The file odbcinst.ini defines the drivers and configuration parameters for the driver manager; odbc.ini defines the data sources. You can check the path of these, after unixODBC is installed by running odbcinst -j, later you can edit those files to adjust whatever fields you need. But for the moment, we’ll use terminal commands (along with our predefined templates) to install the driver and data source.

  1. Install unixODBC using your package manager of choice. On Ubuntu, you can run sudo apt-get install unixodbc. On macOS, run brew install unixodbc.

  2. run odbcinst -i -d -f driver_template

  3. run odbcinst -i -s -f dsn_template

The templates should be adjusted for how you installed your drivers, and however your version of Redis is deployed.

Support

Redis SQL ODBC is supported by Redis, Inc. on a good faith effort basis. To report bugs, request features, or receive assistance, please file an issue.

The Redis SQL ODBC is Copyright © 2023 Redis, Inc.