本文整理汇总了Python中Orange.data.sql.table.SqlTable.download_data方法的典型用法代码示例。如果您正苦于以下问题:Python SqlTable.download_data方法的具体用法?Python SqlTable.download_data怎么用?Python SqlTable.download_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.sql.table.SqlTable
的用法示例。
在下文中一共展示了SqlTable.download_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_XY_large
# 需要导入模块: from Orange.data.sql.table import SqlTable [as 别名]
# 或者: from Orange.data.sql.table.SqlTable import download_data [as 别名]
def test_XY_large(self):
from Orange.data.sql.table import AUTO_DL_LIMIT as DLL
mat = np.random.randint(0, 2, (DLL + 100, 3))
conn, table_name = self.create_sql_table(mat)
sql_table = SqlTable(conn, table_name,
type_hints=Domain([], DiscreteVariable(
name='col2', values=['0', '1', '2'])))
self.assertRaises(ValueError, lambda: sql_table.X)
self.assertRaises(ValueError, lambda: sql_table.Y)
with self.assertRaises(ValueError):
sql_table.download_data(DLL + 10)
# Download partial data
sql_table.download_data(DLL + 10, partial=True)
assert_almost_equal(sql_table.X, mat[:DLL + 10, :2])
assert_almost_equal(sql_table.Y.flatten()[:DLL + 10], mat[:DLL + 10, 2])
# Download all data
sql_table.download_data()
assert_almost_equal(sql_table.X, mat[:, :2])
assert_almost_equal(sql_table.Y.flatten(), mat[:, 2])
示例2: open_table
# 需要导入模块: from Orange.data.sql.table import SqlTable [as 别名]
# 或者: from Orange.data.sql.table.SqlTable import download_data [as 别名]
def open_table(self):
if self.tablecombo.currentIndex() <= 0:
return
if self.tablecombo.currentIndex() < self.tablecombo.count() - 1:
self.table = self.tablecombo.currentText()
else:
self.table = self.sqltext.toPlainText()
table = SqlTable(dict(host=self.host,
port=self.port,
database=self.database,
user=self.username,
password=self.password),
self.table,
inspect_values=False)
sample = False
if table.approx_len() > LARGE_TABLE and self.guess_values:
confirm = QMessageBox(self)
confirm.setIcon(QMessageBox.Warning)
confirm.setText("Attribute discovery might take "
"a long time on large tables.\n"
"Do you want to auto discover attributes?")
confirm.addButton("Yes", QMessageBox.YesRole)
no_button = confirm.addButton("No", QMessageBox.NoRole)
sample_button = confirm.addButton("Yes, on a sample",
QMessageBox.YesRole)
confirm.exec()
if confirm.clickedButton() == no_button:
self.guess_values = False
elif confirm.clickedButton() == sample_button:
sample = True
self.information(1)
if self.guess_values:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if sample:
s = table.sample_time(1)
domain = s.get_domain(guess_values=True)
self.information(
1, "Domain was generated from a sample of the table.")
else:
domain = table.get_domain(guess_values=True)
QApplication.restoreOverrideCursor()
table.domain = domain
if self.download:
if table.approx_len() > MAX_DL_LIMIT:
QMessageBox.warning(
self, 'Warning', "Data is too big to download.\n"
"Consider using the Data Sampler widget to download "
"a sample instead.")
self.download = False
elif table.approx_len() > AUTO_DL_LIMIT:
confirm = QMessageBox.question(
self, 'Question', "Data appears to be big. Do you really "
"want to download it to local memory?",
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if confirm == QMessageBox.No:
self.download = False
if self.download:
table.download_data(MAX_DL_LIMIT)
table = Table(table)
self.send("Data", table)
示例3: get_table
# 需要导入模块: from Orange.data.sql.table import SqlTable [as 别名]
# 或者: from Orange.data.sql.table.SqlTable import download_data [as 别名]
#.........这里部分代码省略.........
"Specify a table name to materialize the query")
return
try:
with self.backend.execute_sql_query("DROP TABLE IF EXISTS " +
self.materialize_table_name):
pass
with self.backend.execute_sql_query("CREATE TABLE " +
self.materialize_table_name +
" AS " + self.sql):
pass
with self.backend.execute_sql_query("ANALYZE " + self.materialize_table_name):
pass
except (psycopg2.ProgrammingError, BackendError) as ex:
self.Error.connection(str(ex))
return
try:
table = SqlTable(dict(host=self.host,
port=self.port,
database=self.database,
user=self.username,
password=self.password),
what,
backend=type(self.backend),
inspect_values=False)
except BackendError as ex:
self.Error.connection(str(ex))
return
self.Error.connection.clear()
sample = False
if table.approx_len() > LARGE_TABLE and self.guess_values:
confirm = QMessageBox(self)
confirm.setIcon(QMessageBox.Warning)
confirm.setText("Attribute discovery might take "
"a long time on large tables.\n"
"Do you want to auto discover attributes?")
confirm.addButton("Yes", QMessageBox.YesRole)
no_button = confirm.addButton("No", QMessageBox.NoRole)
if is_postgres(self.backend):
sample_button = confirm.addButton("Yes, on a sample",
QMessageBox.YesRole)
confirm.exec()
if confirm.clickedButton() == no_button:
self.guess_values = False
elif is_postgres(self.backend) and \
confirm.clickedButton() == sample_button:
sample = True
self.Information.clear()
if self.guess_values:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
if sample:
s = table.sample_time(1)
domain = s.get_domain(inspect_values=True)
self.Information.data_sampled()
else:
domain = table.get_domain(inspect_values=True)
QApplication.restoreOverrideCursor()
table.domain = domain
if self.download:
if table.approx_len() > AUTO_DL_LIMIT:
if is_postgres(self.backend):
confirm = QMessageBox(self)
confirm.setIcon(QMessageBox.Warning)
confirm.setText("Data appears to be big. Do you really "
"want to download it to local memory?")
if table.approx_len() <= MAX_DL_LIMIT:
confirm.addButton("Yes", QMessageBox.YesRole)
no_button = confirm.addButton("No", QMessageBox.NoRole)
sample_button = confirm.addButton("Yes, a sample",
QMessageBox.YesRole)
confirm.exec()
if confirm.clickedButton() == no_button:
return
elif confirm.clickedButton() == sample_button:
table = table.sample_percentage(
AUTO_DL_LIMIT / table.approx_len() * 100)
else:
if table.approx_len() > MAX_DL_LIMIT:
QMessageBox.warning(
self, 'Warning', "Data is too big to download.\n")
return
else:
confirm = QMessageBox.question(
self, 'Question',
"Data appears to be big. Do you really "
"want to download it to local memory?",
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if confirm == QMessageBox.No:
return
table.download_data(MAX_DL_LIMIT)
table = Table(table)
return table