# Path: orangecontrib/spark/utils/data_utils.py
# def pandas_to_orange(df):
#     domain, attributes, metas = construct_domain(df)
#     orange_table = Orange.data.Table.from_numpy(domain = domain, X = df[attributes].values, Y = None, metas = df[metas].values, W = None)
#     return orange_table
# 
# def format_sql(str_sql):
#     return str(sqlparse.format(str_sql, reindent = True, keyword_case = 'upper'))


import os.path
import pyodbc
import pandas as pd
import pandas.io.sql as psql
import Orange
from Orange.widgets.widget import OWWidget
from orangecontrib.spark.utils.data_utils import pandas_to_orange, format_sql
from PyQt4.QtGui import (
    QListView, QSizePolicy, QApplication, QAction, QKeySequence,
    QGraphicsLineItem, QSlider, QPainterPath, QSplitter, QPlainTextEdit, QFileDialog
)
from PyQt4 import QtCore
from Orange.widgets import widget, gui, settings
    def __init__(self):
        super().__init__()
        gui.label(self.controlArea, self, "from pandas:")
        self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        self.allSQLSelectWidgets.append(self)  # set default settings
        self.domain = None
        self.recentConnections = list()
        self.recentConnections.append("(none)")

        self.queryFile = None
        self.query = ''
        self.lastQuery = None
        if self.lastQuery is not None:
            self.query = self.lastQuery

        sources = pyodbc.dataSources()
        dsns = list(sources.keys())
        dsns.sort()

        for dsn in dsns:
            self.recentConnections.append("DSN={dsn}".format(dsn = dsn))

        self.connectString = self.recentConnections[0]

        self.connectBox = gui.widgetBox(self.controlArea, "Database")

        self.connectLineEdit = gui.lineEdit(self.connectBox, self, 'connectString', callback = None)
        self.connectCombo = gui.comboBox(self.connectBox, self, 'connectString', items = self.recentConnections, valueType = str, sendSelectedValue = True)
        self.button = gui.button(self.connectBox, self, 'connect', callback = self.connectDB, disabled = 0)
        # query

# Path: orangecontrib/spark/utils/data_utils.py
# def pandas_to_orange(df):
#     domain, attributes, metas = construct_domain(df)
#     orange_table = Orange.data.Table.from_numpy(domain = domain, X = df[attributes].values, Y = None, metas = df[metas].values, W = None)
#     return orange_table
# 
# def format_sql(str_sql):
#     return str(sqlparse.format(str_sql, reindent = True, keyword_case = 'upper'))


# Path: orangecontrib/spark/widgets/data/odbc_table.py
import os.path
import pyodbc
import pandas as pd
import pandas.io.sql as psql
import Orange
from Orange.widgets.widget import OWWidget
from orangecontrib.spark.utils.data_utils import pandas_to_orange, format_sql
from PyQt4.QtGui import (
    QListView, QSizePolicy, QApplication, QAction, QKeySequence,
    QGraphicsLineItem, QSlider, QPainterPath, QSplitter, QPlainTextEdit, QFileDialog
)
from PyQt4 import QtCore
from Orange.widgets import widget, gui, settings

    def __init__(self):
        super().__init__()
        gui.label(self.controlArea, self, "from pandas:")
        self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        self.allSQLSelectWidgets.append(self)  # set default settings
        self.domain = None
        self.recentConnections = list()
        self.recentConnections.append("(none)")

        self.queryFile = None
        self.query = ''
        self.lastQuery = None
        if self.lastQuery is not None:
            self.query = self.lastQuery

        sources = pyodbc.dataSources()
        dsns = list(sources.keys())
        dsns.sort()

        for dsn in dsns:
            self.recentConnections.append("DSN={dsn}".format(dsn = dsn))

        self.connectString = self.recentConnections[0]

        self.connectBox = gui.widgetBox(self.controlArea, "Database")

        self.connectLineEdit = gui.lineEdit(self.connectBox, self, 'connectString', callback = None)
        self.connectCombo = gui.comboBox(self.connectBox, self, 'connectString', items = self.recentConnections, valueType = str, sendSelectedValue = True)
        self.button = gui.button(self.connectBox, self, 'connect', callback = self.connectDB, disabled = 0)
        # query

        self.splitCanvas = QSplitter(QtCore.Qt.Vertical, self.mainArea)