Forum Discussion
Create SQL views with Fabric lakehouse SQL endpoint from Fabric notebook
Thanks for response
with Solved: Re: Creating views from spark notebook into SQL an... - Microsoft Fabric Community, a pipeline with script to create a view does work
I wonder why pyodbc driver connection could only query the data but cannot create views from SQL endpoint
import pyodbc
server = "?"
database = "?"
username = “?”
pwd = "?"
connection_string = f"Driver={{ODBC Driver 18 for SQL Server}};Server={server};Database={database};Authentication=ActiveDirectoryPassword;UID={username};PWD={pwd};ConnectRetryCount=4"
conn = pyodbc.connect(connection_string)
rows = conn.execute("select top(10) * from dbo.building")
for row in rows:
print(row) # works fine
#following doesn't work
conn.execute("create view dbo.testView as select top(10) * from dbo.building")