How to enable SQL widget in Orange

A lot of you have been interested in enabling SQL widget in Orange, especially regarding the installation of a psycopg backend that makes the widget actually work. This post will be slightly more technical, but I will try to keep it to a minimum. Scroll to the bottom for installation instructions.

Related: SQL for Orange

Why won’t Orange recognize psycopg?

The main issue for some people was that despite having installed the psycopg module in their console, the SQL widget still didn’t work. This is because Orange uses a separate virtual environment and most of you installed psycopg in the default (system) Python environment. For psycopg to be recognized in Orange, it needs to be installed in the same virtual environment, which is normally located in C:\Users\<usr>\Anaconda3\envs\orange3 (on Windows). For the installation to work, you’d have to run it with the proper pip, namely:

C:\Users\<usr>\Anaconda3\envs\orange3\Scripts\pip.exe install psycopg2

Installation instructions

But there is a much easier way to do it. Head over to psycopg’s pip website and download the latest wheel for your platform. Py version has to be cp34 or higher (latest Orange from Anaconda comes with Python 3.6, so look for cp36).

For OSX, you would for example need: psycopg2-2.7.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl

For 64-bit Windows: psycopg2-2.7.4-cp36-cp36m-win_amd64.whl

And for Linux: psycopg2-2.7.4-cp36-cp36m-manylinux1_x86_64.whl

Then open the add-on dialog in Orange (Options –> Add-ons) and drag and drop the downloaded wheel into the add-on list. At the bottom, you will see psycopg2 with the tick next to it.

Click OK to run the installation. Then re-start Orange and connect to your database with SQL widget. If you have any questions, drop them in the comment section!

  • loroferoz

    Hi, I have to connect to a MySQL database (on an Azure server). First, it seems that I need to install Orange/data properly . Is this right? If not, what do I need to install? If this is what I need to do, do I need to get it from github for instance? How can I do this properly for Orange to allow me to connect successfully to a MySQL database?

  • Michael Shparber

    I only see PostgreSQL option – no SQL Server option….
    Please help
    Than you!

    • Ajda Pretnar

      I am not sure what you mean. Where is the mentioned option? What are you trying to achieve?

  • andres

    Maybe you can check sqlalchemy, like the data visualization tool called superset

  • Fotis

    What if someone is using Miniconda and Orange?

    • Ajda Pretnar

      It works the same. In Preferences you will find an Add-on tab, where you can decide to install all add-on with conda (on by default). The entire procedure is the same (see how an Anaconda link is stated above).