Databricks SDK for Python: Errors with parameters for Statement Execution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 07:49 PM
Hi team,
Im using Databricks SDK for python to run SQL queries. I created a variable as below:
param = [{'name' : 'a', 'value' :x'}, {'name' : 'b', 'value' : 'y'}]
and passed it the statement as below
_ = w.statement_execution.execute_statement( warehouse_id = "123", catalog = "aaa", statement = "SELECT * FROM table_a WHERE name = :a and age = :b", parameters = param)
and I get an attribute error: 'dict' object has no attribute 'as_dict'
But this is exactly how databricks instructed on their website. Thank you for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 01:14 PM
@Retired_mod This does not help resolve the issue. I am experiencing the same issue when following the above pointers. Here is the statement:
response = w.statement_execution.execute_statement(
statement='ALTER TABLE users ALTER COLUMN :col_name SET NOT NULL',
warehouse_id='<warehouseID>',
parameters=[{'name': 'col_name', 'value': 'user', 'type': 'STRING'}]
)
This results in the same AttributeError outlined by @Phuonganh above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 07:15 AM
Has anyone found the solution to this? I am running into the same error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2025 10:17 AM
response = w.statement_execution.execute_statement(
statement='ALTER TABLE users ALTER COLUMN :col_name SET NOT NULL',
warehouse_id='<warehouseID>',
parameters=[sql.StatementParameterListItem(name='col_name' value='user', type='STRING')]
)

