本文整理匯總了Python中core.db.connection.DataHubConnection.create_table方法的典型用法代碼示例。如果您正苦於以下問題:Python DataHubConnection.create_table方法的具體用法?Python DataHubConnection.create_table怎麽用?Python DataHubConnection.create_table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core.db.connection.DataHubConnection
的用法示例。
在下文中一共展示了DataHubConnection.create_table方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from core.db.connection import DataHubConnection [as 別名]
# 或者: from core.db.connection.DataHubConnection import create_table [as 別名]
#.........這裏部分代碼省略.........
Should never fail or raise any exceptions.
"""
user = User.objects.get(username=self.username)
return Collaborator.objects.filter(user=user)
def delete_repo(self, repo, force=False):
"""
Deletes a repo.
Pass force=True to delete the repo even if it is not empty.
Returns True on success.
Raises ValueError if repo has invalid characters.
Raises LookupError if the repo doesn't exist.
Raises InternalError if the repo is not empty and force is not True.
Raises PermissionDenied if not repo_base owner.
"""
# Only a repo owner can delete repos.
if self.repo_base != self.username:
raise PermissionDenied()
# remove related collaborator objects
Collaborator.objects.filter(
repo_name=repo, repo_base=self.repo_base).delete()
# finally, delete the actual schema
res = self.user_con.delete_repo(repo=repo, force=force)
DataHubManager.delete_user_data_folder(self.repo_base, repo)
return res
def create_table(self, repo, table, params):
"""
Creates a table in the current repo_base.
Returns True on success.
params = [{'column_name': '', 'data_type': ''} ...]
Raises ValueError if repo, table, or the column names have invalid
characters.
Raises LookupError if the repo doesn't exist.
Raises ValueError if the table already exists.
Raises TypeError if params isn't iterable.
Raises KeyError if params doesn't have the right structure.
Raises ProgrammingError if the params has invalid values.
Raises PermissionDenied on insufficient permissions.
"""
return self.user_con.create_table(
repo=repo, table=table, params=params)
def list_tables(self, repo):
"""
Lists the tables in a repo.
Returns a list of table names.
Raises LookupError on insufficient permissions or if the repo doesn't
exist.
Raises ValueError if repo is invalid.
"""
return sorted(self.user_con.list_tables(repo=repo))
def describe_table(self, repo, table, detail=False):