Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
def test_datasources(self):
p = pyodbc.dataSources()
self.assertTrue(isinstance(p, dict))
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()
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)
# 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()