本文整理匯總了Python中core.db.connection.DataHubConnection.export_view方法的典型用法代碼示例。如果您正苦於以下問題:Python DataHubConnection.export_view方法的具體用法?Python DataHubConnection.export_view怎麽用?Python DataHubConnection.export_view使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core.db.connection.DataHubConnection
的用法示例。
在下文中一共展示了DataHubConnection.export_view方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from core.db.connection import DataHubConnection [as 別名]
# 或者: from core.db.connection.DataHubConnection import export_view [as 別名]
#.........這裏部分代碼省略.........
Raises LookupError on invalid repo or table.
Raises ProgrammingError on invalid combinations of file_format,
delimiter, and header.
Raises PermissionDenied on insufficient privileges.
"""
# clean up names:
repo = clean_str(repo, '')
table = clean_str(table, '')
# check for permissions
DataHubManager.has_repo_db_privilege(
self.username, self.repo_base, repo, 'CREATE')
# make the base_repo and repo's folder, if they don't already exist
DataHubManager.create_user_data_folder(self.repo_base, repo)
# define the file path for the new table
file_name = clean_file_name(file_name)
file_path = user_data_path(
self.repo_base, repo, file_name, file_format)
# format the full table name
table_name = '%s.%s' % (repo, table)
# pass arguments to the connector
self.user_con.export_table(
table_name=table_name,
file_path=file_path,
file_format=file_format,
delimiter=delimiter,
header=header)
def export_view(self, repo, view, file_format='CSV',
delimiter=',', header=True):
"""
Exports a view to a file in the same repo.
Defaults to CSV format with header row.
Raises LookupError on invalid repo or view.
Raises ProgrammingError on invalid combinations of file_format,
delimiter, and header.
Raises PermissionDenied on insufficient privileges.
"""
# clean up names:
repo = clean_str(repo, '')
view = clean_str(view, '')
# check for permissions
DataHubManager.has_repo_db_privilege(
self.username, self.repo_base, repo, 'CREATE')
# make the repo_base and repo's folder, if they don't already exist
DataHubManager.create_user_data_folder(self.repo_base, repo)
# define the file path for the new view
file_name = clean_file_name(view)
file_path = user_data_path(
self.repo_base, repo, file_name, file_format)
# format the full view name
view_name = '%s.%s' % (repo, view)
self.user_con.export_view(
view_name=view_name,