Skip to content

OpenLinkSoftware/Virtuoso-SQLAlchemy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtuoso-SQLAlchemy

A Virtuoso DBMS dialect for SQLAlchemy.

The latest version of this dialect requires SQLAlchemy 1.4 or later.

Objectives

Co-requisites

This SQLAlchemy dialect depends on pyodbc (which depends on a working unixODBC environment). If they are not already in place, this dialect and its dependencies require installation using pip with commands like those below:

  1. pip install pyodbc 
  2. pip install sqlalchemy 
  3. pip install virtuoso-sqlalchemy
    or
    pip install git+https://github.com/OpenLinkSoftware/Virtuoso-SQLAlchemy.git  

Getting Started

Create an ODBC DSN (Data Source Name) that points to your target Virtuoso multi-model DBMS instance via ~/.odbc.ini, as in the following sample:

; Data Source Name and associated Driver Section
; usually titled [ODBC Data Sources]
VOS          = OpenLink Virtuoso ODBC Driver (Unicode)

; Data Source Name and associated Driver Library section
[VOS]
Description = Open Virtuoso
Driver      = /usr/local/virtuoso-opensource/lib/virtodbcu_r.so
Database    = Demo
Address     = localhost:1111
WideAsUTF16 = Yes

NOTE: WideAsUTF16 = Yes is a mandatory attribute. It is used to transform Unicode methods and data in Virtuoso ODBC to the UTF16 character set, as is required by the unixODBC Driver Manager.

Most parameters depend on your installation, but be sure to use virtodbcu_r.so which comprises OpenLink Virtuoso 7.2 ODBC driver or Virtuoso 8.x ODBC driver functionality.

Via SQLAlchemy, DSN binding occurs via a virtuoso+pyodbc scheme URI.

from sqlalchemy import create_engine
engine = create_engine("virtuoso+pyodbc://uid:pwd@your_dsn")

Example

engine = create_engine("virtuoso+pyodbc://dba:dba@VOS")

The SQLAlchemy Project

SQLAlchemy-access is part of the SQLAlchemy Project and adheres to the same standards and conventions as the core project.

Authors