I am trying to publish a single table .hyper extract to our Tableau Enterprise server using the python Tableau Server Client library. I get a Bad request Error. I can connect to the server, get the Project name and id but can't publish.
In the documentations it says " the single table needs to be named
Extract and the table must be in the
Extract schema (or namespace)". What is this "Extract Schema" thing??
I am using the following code, is there an issue with the way I am creating my .hyper file?
# Start a new private local Hyper instance with HyperProcess(Telemetry.SEND_USAGE_DATA_TO_TABLEAU, 'Extract') as hyper: # Create the extract, replace it if it already exists with Connection(hyper.endpoint, 'mydb.hyper', CreateMode.CREATE_AND_REPLACE) as connection: schema = TableDefinition('Extract', [ TableDefinition.Column('a', SqlType.text()), TableDefinition.Column('b', SqlType.big_int()), ]) connection.catalog.create_table(schema) with Inserter(connection, schema) as inserter: inserter.add_rows([ ['x', 1], ['y', 2], ]) inserter.execute()
new_datasource = TSC.DatasourceItem(project_id) new_datasource = server.datasources.publish( new_datasource,'mydb.hyper', 'CreateNew')
400011: Bad Request
There was a problem publishing the file 'mydb.hyper'.
I checked the hyper extract api documentation and did the "Create an extract (python)"
I think the connection.catalog.create_schema line was missing. Thanks Geraldine Zanolli for pointing me in the right direction.
with HyperProcess(Telemetry.SEND_USAGE_DATA_TO_TABLEAU) as hyper: print("The HyperProcess has started.") with Connection(hyper.endpoint, 'TrivialExample.hyper', CreateMode.CREATE_AND_REPLACE) as connection: print("The connection to the Hyper file is open.") connection.catalog.create_schema('Extract') example_table = TableDefinition(TableName('Extract','Extract'), [ TableDefinition.Column('rowID', SqlType.big_int()), TableDefinition.Column('value', SqlType.big_int()), ]) print("The table is defined.") connection.catalog.create_table(example_table) with Inserter(connection, example_table) as inserter: for i in range (1, 101): inserter.add_row( [ i, i ] ) inserter.execute() print("The data was added to the table.") print("The connection to the Hyper extract file is closed.") print("The HyperProcess has shut down.")