Exec Code Python in sql in foreground

Lic. Carlitos Garrido 1 Reputation point
2021-08-13T15:07:02.917+00:00

Hi EveryBody, in first place i send my apollogies for my bad english.

i have a code in python that open a browser with url X... for example "htttps://www.google.com" y try exec in sql there query this way:

EXECUTE sp_execute_external_script @language = N'Python'
, @script = N'
import webbrowser
webbrowser.register("chrome",None,
webbrowser.BackgroundBrowser("C://Program Files//Google//Chrome//Application//chrome.exe"))
webbrowser.get("chrome").open("https://www.google.com")
'
GO

when y type run, the query execute very well in managmetn sql, but the process only showme in the task manager of windows in background.

i need exec in foreground.

i hope can helpme please.

thanks everybody!!!!!

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,897 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 102.3K Reputation points
    2021-08-13T21:47:05.277+00:00

    No, you cannot do that. SQL Server runs as a service and does not have any desktop. The Python script actually runs in a separate process, but that is also a service, and there is no desktop.

    And overall, you don't want to run things from SQL Server that waits for a long time, because that holds up resources, while SQL Server is waiting for the script to complete.

    0 comments No comments