dbrepo package¶
Subpackages¶
- dbrepo.api package
- Submodules
- dbrepo.api.dto module
AccessType
AffiliationIdentifierSchemeType
ApiError
Column
Column.alias
Column.concept
Column.d
Column.data_length
Column.database_id
Column.description
Column.enums
Column.id
Column.index_length
Column.internal_name
Column.is_null_allowed
Column.length
Column.max_data_length
Column.mean
Column.median
Column.model_config
Column.name
Column.num_rows
Column.ord
Column.sets
Column.size
Column.std_dev
Column.table_id
Column.type
Column.unit
Column.val_max
Column.val_min
ColumnBrief
ColumnEnum
ColumnSet
ColumnStatistic
ColumnType
ColumnType.BIGINT
ColumnType.BINARY
ColumnType.BIT
ColumnType.BLOB
ColumnType.BOOL
ColumnType.CHAR
ColumnType.DATE
ColumnType.DATETIME
ColumnType.DECIMAL
ColumnType.DOUBLE
ColumnType.ENUM
ColumnType.FLOAT
ColumnType.INT
ColumnType.LONGBLOB
ColumnType.LONGTEXT
ColumnType.MEDIUMBLOB
ColumnType.MEDIUMINT
ColumnType.MEDIUMTEXT
ColumnType.SERIAL
ColumnType.SET
ColumnType.SMALLINT
ColumnType.TEXT
ColumnType.TIME
ColumnType.TIMESTAMP
ColumnType.TINYBLOB
ColumnType.TINYINT
ColumnType.TINYTEXT
ColumnType.VARBINARY
ColumnType.VARCHAR
ColumnType.YEAR
ConceptBrief
Constraints
Container
ContainerBrief
CreateAccess
CreateContainer
CreateDatabase
CreateForeignKey
CreateIdentifier
CreateIdentifier.creators
CreateIdentifier.database_id
CreateIdentifier.descriptions
CreateIdentifier.doi
CreateIdentifier.execution
CreateIdentifier.funders
CreateIdentifier.language
CreateIdentifier.licenses
CreateIdentifier.model_config
CreateIdentifier.publication_day
CreateIdentifier.publication_month
CreateIdentifier.publication_year
CreateIdentifier.publisher
CreateIdentifier.query
CreateIdentifier.query_id
CreateIdentifier.query_normalized
CreateIdentifier.related_identifiers
CreateIdentifier.result_hash
CreateIdentifier.result_number
CreateIdentifier.table_id
CreateIdentifier.titles
CreateIdentifier.type
CreateIdentifier.view_id
CreateIdentifierCreator
CreateIdentifierCreator.affiliation
CreateIdentifierCreator.affiliation_identifier
CreateIdentifierCreator.affiliation_identifier_scheme
CreateIdentifierCreator.affiliation_identifier_scheme_uri
CreateIdentifierCreator.creator_name
CreateIdentifierCreator.firstname
CreateIdentifierCreator.lastname
CreateIdentifierCreator.model_config
CreateIdentifierCreator.name_identifier
CreateIdentifierCreator.name_identifier_scheme
CreateIdentifierCreator.name_identifier_scheme_uri
CreateIdentifierCreator.name_type
CreateIdentifierDescription
CreateIdentifierFunder
CreateIdentifierTitle
CreateRelatedIdentifier
CreateTable
CreateTableColumn
CreateTableColumn.concept_uri
CreateTableColumn.d
CreateTableColumn.description
CreateTableColumn.enums
CreateTableColumn.index_length
CreateTableColumn.model_config
CreateTableColumn.name
CreateTableColumn.null_allowed
CreateTableColumn.sets
CreateTableColumn.size
CreateTableColumn.type
CreateTableColumn.unit_uri
CreateTableConstraints
CreateUser
CreateView
Creator
Creator.affiliation
Creator.affiliation_identifier
Creator.affiliation_identifier_scheme
Creator.affiliation_identifier_scheme_uri
Creator.creator_name
Creator.firstname
Creator.id
Creator.lastname
Creator.model_config
Creator.name_identifier
Creator.name_identifier_scheme
Creator.name_identifier_scheme_uri
Creator.name_type
CreatorBrief
DataType
DataType.d_default
DataType.d_max
DataType.d_min
DataType.d_required
DataType.data_hint
DataType.display_name
DataType.documentation
DataType.id
DataType.is_buildable
DataType.is_quoted
DataType.model_config
DataType.size_default
DataType.size_max
DataType.size_min
DataType.size_required
DataType.type_hint
DataType.value
Database
Database.accesses
Database.contact
Database.container
Database.description
Database.exchange_name
Database.id
Database.identifiers
Database.internal_name
Database.is_public
Database.is_schema_public
Database.model_config
Database.name
Database.owner
Database.preview_image
Database.subsets
Database.tables
Database.views
DatabaseAccess
DatabaseBrief
DatatypeAnalysis
DescriptionType
Filter
FilterDefinition
FilterType
ForeignKey
ForeignKeyBrief
ForeignKeyReference
History
HistoryEventType
Identifier
Identifier.creators
Identifier.database_id
Identifier.descriptions
Identifier.doi
Identifier.execution
Identifier.funders
Identifier.id
Identifier.language
Identifier.licenses
Identifier.links
Identifier.model_config
Identifier.owner
Identifier.publication_day
Identifier.publication_month
Identifier.publication_year
Identifier.publisher
Identifier.query
Identifier.query_id
Identifier.query_normalized
Identifier.related_identifiers
Identifier.result_hash
Identifier.result_number
Identifier.status
Identifier.table_id
Identifier.titles
Identifier.type
Identifier.view_id
IdentifierBrief
IdentifierBrief.database_id
IdentifierBrief.doi
IdentifierBrief.id
IdentifierBrief.model_config
IdentifierBrief.owned_by
IdentifierBrief.publication_year
IdentifierBrief.publisher
IdentifierBrief.query_id
IdentifierBrief.status
IdentifierBrief.table_id
IdentifierBrief.titles
IdentifierBrief.type
IdentifierBrief.view_id
IdentifierDescription
IdentifierFunder
IdentifierSave
IdentifierStatusType
IdentifierTitle
IdentifierType
Image
ImageBrief
Import
KeyAnalysis
Language
Language.AA
Language.AB
Language.AE
Language.AF
Language.AK
Language.AM
Language.AN
Language.AR
Language.AS
Language.AV
Language.AY
Language.AZ
Language.BA
Language.BE
Language.BG
Language.BH
Language.BI
Language.BM
Language.BN
Language.BO
Language.BR
Language.BS
Language.CA
Language.CE
Language.CH
Language.CO
Language.CR
Language.CS
Language.CU
Language.CV
Language.CY
Language.DA
Language.DE
Language.DV
Language.DZ
Language.EE
Language.EL
Language.EN
Language.EO
Language.ES
Language.ET
Language.EU
Language.FA
Language.FF
Language.FI
Language.FJ
Language.FO
Language.FR
Language.FY
Language.GA
Language.GD
Language.GL
Language.GN
Language.GU
Language.GV
Language.HA
Language.HE
Language.HI
Language.HO
Language.HR
Language.HT
Language.HU
Language.HY
Language.HZ
Language.IA
Language.ID
Language.IE
Language.IG
Language.II
Language.IK
Language.IO
Language.IS
Language.IT
Language.IU
Language.JA
Language.JV
Language.KA
Language.KG
Language.KI
Language.KJ
Language.KK
Language.KL
Language.KM
Language.KN
Language.KO
Language.KR
Language.KS
Language.KU
Language.KV
Language.KW
Language.KY
Language.LA
Language.LB
Language.LG
Language.LI
Language.LN
Language.LO
Language.LT
Language.LU
Language.LV
Language.MG
Language.MH
Language.MI
Language.MK
Language.ML
Language.MN
Language.MR
Language.MS
Language.MT
Language.MY
Language.NA
Language.NB
Language.ND
Language.NE
Language.NG
Language.NL
Language.NN
Language.NO
Language.NR
Language.NV
Language.NY
Language.OC
Language.OJ
Language.OM
Language.OR
Language.OS
Language.PA
Language.PI
Language.PL
Language.PS
Language.PT
Language.QU
Language.RM
Language.RN
Language.RO
Language.RU
Language.RW
Language.SA
Language.SC
Language.SD
Language.SE
Language.SG
Language.SI
Language.SK
Language.SL
Language.SM
Language.SN
Language.SO
Language.SQ
Language.SR
Language.SS
Language.ST
Language.SU
Language.SV
Language.SW
Language.TA
Language.TE
Language.TG
Language.TH
Language.TI
Language.TK
Language.TL
Language.TN
Language.TO
Language.TR
Language.TS
Language.TT
Language.TW
Language.TY
Language.UG
Language.UK
Language.UR
Language.UZ
Language.VE
Language.VI
Language.VO
Language.WA
Language.WO
Language.XH
Language.YI
Language.YO
Language.ZA
Language.ZH
Language.ZU
License
Links
Message
ModifyOwner
ModifyVisibility
NameIdentifierSchemeType
OntologyBrief
Operator
Order
OrderDefinition
OrderType
PrimaryKey
Query
QueryDefinition
QueryType
ReferenceType
RelatedIdentifier
RelatedIdentifierRelation
RelatedIdentifierRelation.CITES
RelatedIdentifierRelation.COMPILES
RelatedIdentifierRelation.CONTINUES
RelatedIdentifierRelation.DESCRIBES
RelatedIdentifierRelation.DOCUMENTS
RelatedIdentifierRelation.HAS_METADATA
RelatedIdentifierRelation.HAS_PART
RelatedIdentifierRelation.HAS_VERSION
RelatedIdentifierRelation.IS_CITED_BY
RelatedIdentifierRelation.IS_COMPILED_BY
RelatedIdentifierRelation.IS_CONTINUED_BY
RelatedIdentifierRelation.IS_DERIVED_FROM
RelatedIdentifierRelation.IS_DESCRIBED_BY
RelatedIdentifierRelation.IS_DOCUMENTED_BY
RelatedIdentifierRelation.IS_IDENTICAL_TO
RelatedIdentifierRelation.IS_METADATA_FOR
RelatedIdentifierRelation.IS_NEW_VERSION_OF
RelatedIdentifierRelation.IS_OBSOLETED_BY
RelatedIdentifierRelation.IS_ORIGINAL_FORM_OF
RelatedIdentifierRelation.IS_PART_OF
RelatedIdentifierRelation.IS_PREVIOUS_VERSION_OF
RelatedIdentifierRelation.IS_PUBLISHED_IN
RelatedIdentifierRelation.IS_REFERENCED_BY
RelatedIdentifierRelation.IS_REQUIRED_BY
RelatedIdentifierRelation.IS_REVIEWED_BY
RelatedIdentifierRelation.IS_SOURCE_OF
RelatedIdentifierRelation.IS_SUPPLEMENTED_BY
RelatedIdentifierRelation.IS_SUPPLEMENT_TO
RelatedIdentifierRelation.IS_VARIANT_FORM_OF
RelatedIdentifierRelation.IS_VERSION_OF
RelatedIdentifierRelation.OBSOLETES
RelatedIdentifierRelation.REFERENCES
RelatedIdentifierRelation.REQUIRES
RelatedIdentifierRelation.REVIEWS
RelatedIdentifierType
RelatedIdentifierType.ARK
RelatedIdentifierType.ARXIV
RelatedIdentifierType.BIBCODE
RelatedIdentifierType.DOI
RelatedIdentifierType.EAN13
RelatedIdentifierType.EISSN
RelatedIdentifierType.HANDLE
RelatedIdentifierType.IGSN
RelatedIdentifierType.ISBN
RelatedIdentifierType.ISTC
RelatedIdentifierType.LISSN
RelatedIdentifierType.LSID
RelatedIdentifierType.PMID
RelatedIdentifierType.PURL
RelatedIdentifierType.UPC
RelatedIdentifierType.URL
RelatedIdentifierType.URN
RelatedIdentifierType.W3ID
SaveIdentifierCreator
SaveIdentifierDescription
SaveIdentifierFunder
SaveIdentifierTitle
SaveRelatedIdentifier
Subset
Table
Table.avg_row_length
Table.columns
Table.constraints
Table.data_length
Table.database_id
Table.description
Table.id
Table.identifiers
Table.internal_name
Table.is_public
Table.is_schema_public
Table.is_versioned
Table.max_data_length
Table.model_config
Table.name
Table.num_rows
Table.owner
Table.queue_name
Table.queue_type
Table.routing_key
TableBrief
TableStatistics
TitleType
Tuple
TupleDelete
TupleUpdate
Unique
UnitBrief
UpdateAccess
UpdateColumn
UpdateQuery
UpdateUser
UpdateUserPassword
UpdateUserTheme
UpdateView
UploadResponse
User
UserAttributes
UserBrief
View
ViewBrief
ViewColumn
ViewColumn.alias
ViewColumn.concept
ViewColumn.d
ViewColumn.database_id
ViewColumn.id
ViewColumn.index_length
ViewColumn.internal_name
ViewColumn.is_null_allowed
ViewColumn.length
ViewColumn.mean
ViewColumn.median
ViewColumn.model_config
ViewColumn.name
ViewColumn.ord
ViewColumn.size
ViewColumn.type
ViewColumn.unit
- dbrepo.api.exceptions module
- Module contents
Submodules¶
dbrepo.RestClient module¶
- class dbrepo.RestClient.RestClient(endpoint: str = 'http://localhost', username: str = None, password: str = None, secure: bool = True)¶
Bases:
object
The RestClient class for communicating with the DBRepo REST API. All parameters can be set also via environment variables, e.g. set endpoint with REST_API_ENDPOINT, username with REST_API_USERNAME, etc. You can override the constructor parameters with the environment variables.
- Parameters:
endpoint – The REST API endpoint. Optional. Default: “http://gateway-service”
username – The REST API username. Optional.
password – The REST API password. Optional.
secure – When set to false, the requests library will not verify the authenticity of your TLS/SSL certificates (i.e. when using self-signed certificates). Default: True.
- analyse_datatypes(dataframe: DataFrame, enum: bool = None, enum_tol: int = None) DatatypeAnalysis ¶
Import a csv dataset from a file and analyse it for the possible enums, line encoding and column data types.
- Parameters:
dataframe – The dataframe.
enum – If set to true, enumerations should be guessed, otherwise no guessing. Optional.
enum_tol – The tolerance for guessing enumerations (ignored if enum=False). Optional.
- Returns:
The determined data types, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
NotExistsError – If the file was not found by the Analyse Service.
ResponseCodeError – If something went wrong with the analysis.
- analyse_keys(dataframe: DataFrame) KeyAnalysis ¶
Import a csv dataset from a file and analyse it for the possible primary key.
- Parameters:
dataframe – The dataframe.
- Returns:
The determined ranking of the primary key candidates, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
NotExistsError – If the file was not found by the Analyse Service.
ResponseCodeError – If something went wrong with the analysis.
- analyse_table_statistics(database_id: str, table_id: str) TableStatistics ¶
Analyses the numerical contents of a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
- Returns:
The table statistics, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
NotExistsError – If the file was not found by the Analyse Service.
ServiceConnectionError – If something went wrong with connection to the metadata service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the analysis.
- create_container(name: str, host: str, image_id: str, privileged_username: str, privileged_password: str, port: int = None, ui_host: str = None, ui_port: int = None) Container ¶
Register a container instance executing a given container image. Note that this does not create a container, but only saves it in the metadata database to be used within DBRepo. The container still needs to be created through e.g. docker run image:tag -d.
- Parameters:
name – The container name.
host – The container hostname.
image_id – The container image id.
privileged_username – The container privileged user username.
privileged_password – The container privileged user password.
port – The container port bound to the host. Optional.
ui_host – The container hostname displayed in the user interface. Optional. Default: value of host.
ui_port – The container port displayed in the user interface. Optional. Default: default_port of image.
- Returns:
The container, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
NameExistsError – If a container with this name already exists.
ResponseCodeError – If something went wrong with the retrieval.
- create_database(name: str, container_id: str, is_public: bool = True, is_schema_public: bool = True) Database ¶
Create a databases in a container with given container id.
- Parameters:
name – The name of the database.
container_id – The container id.
is_public – The visibility of the data. If set to true the data will be publicly visible. Optional. Default: True.
is_schema_public – The visibility of the schema metadata. If set to true the schema metadata will be publicly visible. Optional. Default: True.
- Returns:
The database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
QueryStoreError – If something went wrong with the query store.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the retrieval.
- create_database_access(database_id: str, user_id: str, type: AccessType) AccessType ¶
Create access to a database with given database id and user id.
- Parameters:
database_id – The database id.
user_id – The user id.
type – The access type.
- Returns:
The access type, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- create_identifier(database_id: str, type: IdentifierType, titles: List[CreateIdentifierTitle], publisher: str, creators: List[CreateIdentifierCreator], publication_year: int, descriptions: List[CreateIdentifierDescription] = None, funders: List[CreateIdentifierFunder] = None, licenses: List[License] = None, language: Language = None, subset_id: str = None, view_id: str = None, table_id: str = None, publication_day: int = None, publication_month: int = None, related_identifiers: List[CreateRelatedIdentifier] = None) Identifier ¶
Create an identifier draft.
- Parameters:
database_id – The database id of the created identifier.
type – The type of the created identifier.
titles – The titles of the created identifier.
publisher – The publisher of the created identifier.
creators – The creator(s) of the created identifier.
publication_year – The publication year of the created identifier.
descriptions – The description(s) of the created identifier. Optional.
funders – The funders(s) of the created identifier. Optional.
licenses – The license(s) of the created identifier. Optional.
language – The language of the created identifier. Optional.
subset_id – The subset id of the created identifier. Required when type=SUBSET, otherwise invalid. Optional.
view_id – The view id of the created identifier. Required when type=VIEW, otherwise invalid. Optional.
table_id – The table id of the created identifier. Required when type=TABLE, otherwise invalid. Optional.
publication_day – The publication day of the created identifier. Optional.
publication_month – The publication month of the created identifier. Optional.
related_identifiers – The related identifier(s) of the created identifier. Optional.
- Returns:
The identifier, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table/view/subset or user does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the creation of the identifier.
- create_subset(database_id: str, query: QueryDefinition, page: int = 0, size: int = 10, timestamp: datetime = None) DataFrame ¶
Executes a SQL query in a database where the current user has at least read access with given database id. The result set can be paginated with setting page and size (both). Historic data can be queried by setting timestamp.
- Parameters:
database_id – The database id.
query – The query definition.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
timestamp – The timestamp at which the data validity is set. Optional. Default: <current timestamp>.
- Returns:
The result set, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table or user does not exist.
QueryStoreError – The query store rejected the query.
FormatNotAvailable – The subset query contains non-supported keywords.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- create_table(database_id: str, name: str, is_public: bool, is_schema_public: bool, dataframe: DataFrame, description: str = None, with_data: bool = True) TableBrief ¶
Updates the database owner of a database with given database id.
- Parameters:
database_id – The database id.
name – The name of the created table.
is_public – The visibility of the data. If set to true the data will be publicly visible.
is_schema_public – The visibility of the schema metadata. If set to true the schema metadata will be publicly visible.
dataframe – The pandas dataframe.
description – The description of the created table. Optional.
with_data – If set to True, the data will be included in the new table. Optional. Default: True.
- Returns:
The table, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
NameExistsError – If a table with this name already exists.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the creation.
- create_table_data(database_id: str, table_id: str, data: dict) None ¶
Insert data into a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
data – The data dictionary to be inserted into the table with the form column=value of the table.
- Raises:
MalformedError – If the payload is rejected by the service (e.g. LOB could not be imported).
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the insert.
- create_view(database_id: str, name: str, query: QueryDefinition, is_public: bool, is_schema_public: bool) ViewBrief ¶
Create a view in a database with given database id.
- Parameters:
database_id – The database id.
name – The name of the created view.
query – The query definition of the view.
is_public – The visibility of the data. If set to true the data will be publicly visible. Optional. Default: True.
is_schema_public – The visibility of the schema metadata. If set to true the schema metadata will be publicly visible. Optional. Default: True.
- Returns:
The created view, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ExternalSystemError – If the mapped view creation query is erroneous.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the retrieval.
- delete_container(container_id: str) None ¶
Deletes a container with given id. Note that this does not delete the container, but deletes the entry in the metadata database. The container still needs to be removed, e.g. docker container stop hash and then docker container rm hash.
- Parameters:
container_id – The container id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the deletion.
- delete_database_access(database_id: str, user_id: str) None ¶
Deletes the access for a user to a database with given database id and user id.
- Parameters:
database_id – The database id.
user_id – The user id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- delete_table(database_id: str, table_id: str) None ¶
Delete a table with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the deletion.
- delete_table_data(database_id: str, table_id: str, keys: dict) None ¶
Delete data in a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
keys – The key dictionary matching the rows in the form column=value.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the deletion.
- delete_view(database_id: str, view_id: str) None ¶
Deletes a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ExternalSystemError – If the mapped view deletion query is erroneous.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the deletion.
- endpoint: str = None¶
- get_concepts() List[ConceptBrief] ¶
Get list of concepts known to the metadata database.
- Returns:
List of concepts, if successful.
- get_container(container_id: str) Container ¶
Get a container with given id.
- Returns:
List of containers, if successful.
- Raises:
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_containers() List[ContainerBrief] ¶
Get all containers.
- Returns:
List of containers, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_database(database_id: str) Database ¶
Get a databases with given id.
- Parameters:
database_id – The database id.
- Returns:
The database, if successful.
- Raises:
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_database_access(database_id: str) AccessType ¶
Get access of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
- Returns:
The access type, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_databases() List[DatabaseBrief] ¶
Get all databases.
- Returns:
List of databases, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_databases_count() int ¶
Count all databases.
- Returns:
Count of databases if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_identifier(identifier_id: str) Identifier ¶
Get the identifier by given id.
- Parameters:
identifier_id – The identifier id.
- Returns:
The identifier, if successful.
- Raises:
NotExistsError – If the identifier does not exist.
ResponseCodeError – If something went wrong with the retrieval of the identifier.
- get_identifier_data(identifier_id: str) DataFrame ¶
Get the identifier data by given id.
- Parameters:
identifier_id – The identifier id.
- Returns:
The identifier, if successful.
- Raises:
NotExistsError – If the identifier does not exist.
ResponseCodeError – If something went wrong with the retrieval of the identifier.
- get_identifiers(database_id: str = None, subset_id: str = None, view_id: str = None, table_id: str = None, type: IdentifierType = None, status: IdentifierStatusType = None) List[Identifier] ¶
Get list of identifiers, filter by the remaining optional arguments.
- Parameters:
database_id – The database id. Optional.
subset_id – The subset id. Optional. Requires database_id to be set.
view_id – The view id. Optional. Requires database_id to be set.
table_id – The table id. Optional. Requires database_id to be set.
type – The identifier type. Optional.
status – The identifier status. Optional.
- Returns:
List of identifiers, if successful.
- Raises:
NotExistsError – If the accept header is neither application/json nor application/ld+json.
FormatNotAvailable – If the service could not represent the output.
ResponseCodeError – If something went wrong with the retrieval of the identifiers.
- get_image(image_id: str) Image ¶
Get container image.
- Parameters:
image_id – The image id.
- Returns:
The image, if successful.
- Raises:
NotExistsError – If the image does not exist.
ResponseCodeError – If something went wrong with the retrieval of the image.
- get_images() List[ImageBrief] ¶
Get list of container images.
- Returns:
List of images, if successful.
- get_licenses() List[License] ¶
Get list of licenses allowed.
- Returns:
List of licenses, if successful.
- get_ontologies() List[OntologyBrief] ¶
Get list of ontologies.
- Returns:
List of ontologies, if successful.
- get_queries(database_id: str) List[Query] ¶
Get queries from a database with given database id.
- Parameters:
database_id – The database id.
- Returns:
List of queries, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_subset(database_id: str, subset_id: str) Query ¶
Get query from a database with given database id and query id.
- Parameters:
database_id – The database id.
subset_id – The subset id.
- Returns:
The query, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, query or user does not exist.
FormatNotAvailable – If the service could not represent the output.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_subset_data(database_id: str, subset_id: str, page: int = 0, size: int = 10) DataFrame ¶
Re-executes a query in a database with given database id and query id.
- Parameters:
database_id – The database id.
subset_id – The subset id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
size – The result pagination size. Optional. Default: 10.
- Returns:
The subset data, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, query or user does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_subset_data_count(database_id: str, subset_id: str) int ¶
Re-executes a query in a database with given database id and query id and only counts the results.
- Parameters:
database_id – The database id.
subset_id – The subset id.
- Returns:
The result set, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, query or user does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table(database_id: str, table_id: str) Table ¶
Get a table with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
- Returns:
List of tables, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_data(database_id: str, table_id: str, page: int = 0, size: int = 10, timestamp: datetime = None) DataFrame ¶
Get data of a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
timestamp – The query execution time. Optional.
- Returns:
The table data, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_data_count(database_id: str, table_id: str, timestamp: datetime = None) int ¶
Get data count of a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
timestamp – The query execution time. Optional.
- Returns:
The result of the view query, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ExternalSystemError – If the mapped view selection query is erroneous.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_table_history(database_id: str, table_id: str, size: int = 100) [<class 'dbrepo.api.dto.History'>] ¶
Get the table history of insert/delete operations.
- Parameters:
database_id – The database id.
table_id – The table id.
size – The number of operations. Optional. Default: 100.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- get_tables(database_id: str) List[TableBrief] ¶
Get all tables.
- Parameters:
database_id – The database id.
- Returns:
List of tables, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_units() List[UnitBrief] ¶
Get all units known to the metadata database.
- Returns:
List of units, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_user(user_id: str) User ¶
Get a user with given user id.
- Returns:
The user, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the user does not exist.
- get_users() List[UserBrief] ¶
Get all users.
- Returns:
List of users, if successful.
- Raises:
ResponseCodeError – If something went wrong with the retrieval.
- get_view(database_id: str, view_id: str) View ¶
Get a view of a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
- Returns:
The view, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- get_view_data(database_id: str, view_id: str, page: int = 0, size: int = 10) DataFrame ¶
Get data of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
page – The result pagination number. Optional. Default: 0.
size – The result pagination size. Optional. Default: 10.
- Returns:
The view data, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the view does not exist.
ExternalSystemError – If the mapped view selection query is erroneous.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_view_data_count(database_id: str, view_id: str) int ¶
Get data count of a view in a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
- Returns:
The result count of the view query, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the view does not exist.
ExternalSystemError – If the mapped view selection query is erroneous.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the retrieval.
- get_views(database_id: str) List[ViewBrief] ¶
Gets views of a database with given database id.
- Parameters:
database_id – The database id.
- Returns:
The list of views, if successful.
- Raises:
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- import_table_data(database_id: str, table_id: str, dataframe: DataFrame) None ¶
Import a csv dataset from a file into a table in a database with given database id and table id. ATTENTION: the import is column-ordering sensitive! The csv dataset must have the same columns in the same order as the target table.
- Parameters:
database_id – The database id.
table_id – The table id.
dataframe – The pandas dataframe.
- Raises:
MalformedError – If the payload is rejected by the service (e.g. LOB could not be imported).
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the insert.
- password: str = None¶
- publish_identifier(identifier_id: str) Identifier ¶
Publish an identifier with given id.
- Parameters:
identifier_id – The identifier id.
- Returns:
The identifier, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table/view/subset or user does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the creation of the identifier.
- secure: bool = None¶
- update_database_access(database_id: str, user_id: str, type: AccessType) AccessType ¶
Updates the access for a user to a database with given database id and user id.
- Parameters:
database_id – The database id.
user_id – The user id.
type – The access type.
- Returns:
The access type, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- update_database_owner(database_id: str, user_id: str) Database ¶
Updates the database owner of a database with given database id.
- Parameters:
database_id – The database id.
user_id – The user id of the new owner.
- Returns:
The database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the update.
- update_database_schema(database_id: str) DatabaseBrief ¶
Updates the database table and view metadata of a database with given database id.
- Parameters:
database_id – The database id.
- Returns:
The updated database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ServiceConnectionError – If something went wrong with connection to the data service.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the update.
- update_database_visibility(database_id: str, is_public: bool, is_schema_public: bool) Database ¶
Updates the database visibility of a database with given database id.
- Parameters:
database_id – The database id.
is_public – The visibility of the data. If set to true the data will be publicly visible.
is_schema_public – The visibility of the schema metadata. If set to true the schema metadata will be publicly visible.
- Returns:
The database, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the update.
- update_identifier(identifier_id: str, database_id: str, type: IdentifierType, titles: List[SaveIdentifierTitle], publisher: str, creators: List[SaveIdentifierCreator], publication_year: int, descriptions: List[SaveIdentifierDescription] = None, funders: List[SaveIdentifierFunder] = None, licenses: List[License] = None, language: Language = None, subset_id: str = None, view_id: str = None, table_id: str = None, publication_day: int = None, publication_month: int = None, related_identifiers: List[SaveRelatedIdentifier] = None) Identifier ¶
Update an existing identifier and update the metadata attached to it.
- Parameters:
identifier_id – The identifier id.
database_id – The database id of the created identifier.
type – The type of the created identifier.
titles – The titles of the created identifier.
publisher – The publisher of the created identifier.
creators – The creator(s) of the created identifier.
publication_year – The publication year of the created identifier.
descriptions – The description(s) of the created identifier. Optional.
funders – The funders(s) of the created identifier. Optional.
licenses – The license(s) of the created identifier. Optional.
language – The language of the created identifier. Optional.
subset_id – The subset id of the created identifier. Required when type=SUBSET, otherwise invalid. Optional.
view_id – The view id of the created identifier. Required when type=VIEW, otherwise invalid. Optional.
table_id – The table id of the created identifier. Required when type=TABLE, otherwise invalid. Optional.
publication_day – The publication day of the created identifier. Optional.
publication_month – The publication month of the created identifier. Optional.
related_identifiers – The related identifier(s) of the created identifier. Optional.
- Returns:
The identifier, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database, table/view/subset or user does not exist.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the creation of the identifier.
- update_subset(database_id: str, subset_id: str, persist: bool) Query ¶
Save query or mark it for deletion (at a later time) in a database with given database id and query id.
- Parameters:
database_id – The database id.
subset_id – The subset id.
persist – If set to true, the query will be saved and visible in the user interface, otherwise the query is marked for deletion in the future and not visible in the user interface.
- Returns:
The query, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the database or user does not exist.
QueryStoreError – The query store rejected the update.
ServiceError – If something went wrong with obtaining the information in the data service.
ResponseCodeError – If something went wrong with the retrieval.
- update_table_column(database_id: str, table_id: str, column_id: str, concept_uri: str = None, unit_uri: str = None) Column ¶
Update semantic information of a table column by given database id and table id and column id.
- Parameters:
database_id – The database id.
table_id – The table id.
column_id – The column id.
concept_uri – The concept URI. Optional.
unit_uri – The unit URI. Optional.
- Returns:
The column, if successful.
- Raises:
MalformedError – If the payload is rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the accept header is neither application/json nor application/ld+json.
ServiceConnectionError – If something went wrong with connection to the search service.
ServiceError – If something went wrong with obtaining the information in the search service.
ResponseCodeError – If something went wrong with the retrieval of the identifiers.
- update_table_data(database_id: str, table_id: str, data: dict, keys: dict) None ¶
Update data in a table in a database with given database id and table id.
- Parameters:
database_id – The database id.
table_id – The table id.
data – The data dictionary to be updated into the table with the form column=value of the table.
keys – The key dictionary matching the rows in the form column=value.
- Raises:
MalformedError – If the payload is rejected by the service (e.g. LOB data could not be imported).
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the table does not exist.
ServiceError – If something went wrong with obtaining the information in the metadata service.
ResponseCodeError – If something went wrong with the update.
- update_user(user_id: str, theme: str, language: str, firstname: str = None, lastname: str = None, affiliation: str = None, orcid: str = None) UserBrief ¶
Updates a user with given user id.
- Parameters:
user_id – The user id of the user that should be updated.
theme – The user theme. One of “light”, “dark”, “light-contrast”, “dark-contrast”.
language – The user language localization. One of “en”, “de”.
firstname – The updated given name. Optional.
lastname – The updated family name. Optional.
affiliation – The updated affiliation identifier. Optional.
orcid – The updated ORCID identifier. Optional.
- Returns:
The user, if successful.
- Raises:
MalformedError – If the payload was rejected by the service.
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the user does not exist.
ResponseCodeError – If something went wrong with the update.
- update_view(database_id: str, view_id: str, is_public: bool, is_schema_public: bool) ViewBrief ¶
Get a view of a database with given database id and view id.
- Parameters:
database_id – The database id.
view_id – The view id.
is_public – If set to True, the view data is publicly visible.
is_schema_public – If set to True, the view schema is publicly visible.
- Returns:
The view, if successful.
- Raises:
ForbiddenError – If something went wrong with the authorization.
NotExistsError – If the container does not exist.
ResponseCodeError – If something went wrong with the retrieval.
- username: str = None¶
- whoami() str | None ¶
Print the username.
- Returns:
The username, if set.