The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a control table in in fabric data warehouse .I need to update the control table from spark notebook.
Hi @Anonymous ,
Is my follow-up just to ask if the problem has been solved?
If so, can you accept the correct answer as a solution or share your solution to help other members find it faster?
Thank you very much for your cooperation!
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @Anonymous ,
Thanks for the reply from frithjof_v .
To update the table in the Fabric Data Warehouse from Lakehouse's notebook, you can use Pyodbc, here is an example:
import pyodbc
# SQL endpoint from your Lakehouse or Warehouse
server = "your_SQL endpoint"
# Name of the Lakehouse or Warehouse
database = "databaseName"
# Service principal credentials
clientId = "xxxxx"
clientSecret = "xxxxx"
# Connection string
constr = f"driver=ODBC Driver 18 for SQL Server;server={server};database={database};UID={clientId};PWD={clientSecret};Authentication=ActiveDirectoryServicePrincipal;Encrypt=yes;Timeout=60;"
# Connect to the database
con = pyodbc.connect(constr)
cursor = con.cursor()
# SQL command to rename the column in DimProduct table
update_command = """
ALTER TABLE DimProduct
RENAME COLUMN ProductName TO Name;
"""
# Execute the command
cursor.execute(update_command)
con.commit()
# Close the connection
cursor.close()
con.close()
print("Update successful")
Replace server, database, clientId, and clientSecret with your own information.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
I executed this code with my credentials and details but got this error. Any idea
InterfaceError: ('28000', '[28000] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Could not login because the authentication failed. (18456) (SQLDriverConnect)')
Perhaps you can use Pyodbc:
https://debruyn.dev/2023/connect-to-fabric-lakehouses-warehouses-from-python-code/
I never tried it myself
User | Count |
---|---|
17 | |
9 | |
5 | |
3 | |
3 |
User | Count |
---|---|
46 | |
22 | |
17 | |
13 | |
12 |