Closed HudsonMC16 closed 4 years ago
Hi Hudson, I did make some significant changes to the tableau_documents portion of the library, specifically these areas, to try and give a more unified syntax. If you look in the README at sections 2.4.5, the new naming conventions are there. You access the Custom SQL via 'TableauDatasource.tables.main_custom_sql' now rather than the old way.
Let me know if you hit any errors once you updated based on the new properties.
Thanks, Bryant! I will try this and see how it goes.
ah, Unfortunately, I have to report that this isn't quite working. Despite the template file clearly containing a pre-existing custom sql string, I'm getting this error:
InvalidOptionException('Data Source does not have Custom SQL defined')
when using the following code:
sql = self.GenerateSQL()
tf = TableauFileManager.open(filename="template.twb")
ds = tf.datasources[0]
ds.tables.main_custom_sql = sql
It looks like, from the tableau_documents code here: https://github.com/bryantbhowell/tableau_tools/blob/1bd2dfed5c56dd2aec64eeb30572f960e8413af3/tableau_documents/table_relations.py#L49
you're checking if the type is stored-proc. In my case, the main_table_type is "custom-sql"
EDIT: Actually, I take that back. ds.main_table_type is "custom-sql". ds.tables.main_table.attrib['type'] is "text". Not sure if these should match, or what exactly the meaning of these two parameters is.
Should we re-open this issue?
In a previous version of tableau tools, I was able to use the following code to create workbooks from a template workbook with different custom sql queries:
but this code now results in the following error on the last line:
It appears the structure of the tableau_document class has changed? Is it still possible to manipulate custom sql queries in this manner?