How to use the pyodbc.dataSources function in pyodbc

To help you get started, we’ve selected a few pyodbc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mkleehammer / pyodbc / tests2 / sqlservertests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github mkleehammer / pyodbc / tests3 / mysqltests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github mkleehammer / pyodbc / tests2 / accesstests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github mkleehammer / pyodbc / tests2 / freetdstests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github mkleehammer / pyodbc / tests2 / pgtests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github mkleehammer / pyodbc / tests2 / sqlitetests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github mkleehammer / pyodbc / tests2 / informixtests.py View on Github external
def test_datasources(self):
        p = pyodbc.dataSources()
        self.assertTrue(isinstance(p, dict))
github Spine-project / Spine-Toolbox / spinetoolbox / project_items / data_store / data_store.py View on Github external
def enable_dialect(self, dialect):
        """Enable the given dialect in the item controls."""
        if dialect == "":
            self.enable_no_dialect()
        elif dialect == 'sqlite':
            self.enable_sqlite()
        elif dialect == 'mssql':
            import pyodbc  # pylint: disable=import-outside-toplevel

            dsns = pyodbc.dataSources()
            # Collect dsns which use the msodbcsql driver
            mssql_dsns = list()
            for key, value in dsns.items():
                if 'msodbcsql' in value.lower():
                    mssql_dsns.append(key)
            if mssql_dsns:
                self._properties_ui.comboBox_dsn.clear()
                self._properties_ui.comboBox_dsn.addItems(mssql_dsns)
                self._properties_ui.comboBox_dsn.setCurrentIndex(-1)
                self.enable_mssql()
            else:
                msg = "Please create a SQL Server ODBC Data Source first."
                self._logger.msg_warning.emit(msg)
        else:
            self.enable_common()
github jamartinh / Orange3-Spark / orangecontrib / spark / widgets / data / odbc_table.py View on Github external
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)
        self.mainArea.layout().addWidget(self.splitCanvas)
github Spine-project / Spine-Toolbox / spinetoolbox / widgets / add_connection_string_widget.py View on Github external
# Setup UI from Qt Designer file
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        # Class attributes
        self._parent = parent
        self._data_store = data_store
        self.string_dict = dict()
        # Add status bar to form
        self.statusbar = QStatusBar(self)
        self.statusbar.setFixedHeight(20)
        self.statusbar.setSizeGripEnabled(False)
        self.statusbar.setStyleSheet(STATUSBAR_SS)
        self.ui.horizontalLayout_statusbar_placeholder.addWidget(self.statusbar)
        # init ui
        self.ui.comboBox_dsn.addItem("Select data source name...")
        self.data_sources = pyodbc.dataSources() # this is a dict
        self.ui.comboBox_dsn.addItems(list(self.data_sources.keys()))
        self.ui.comboBox_dsn.setFocus()
        self.connect_signals()