question

LicCarlitosGarrido-0009 avatar image
0 Votes"
LicCarlitosGarrido-0009 asked AmeliaGu-msft commented

Exec Code Python in sql in foreground

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-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi LicCarlitosGarrido-0009,

How are things going on?
Did the answer help you?
Please feel free to let us know if you have any other question.
If you find any post in the thread is helpful, you could kindly accept it as answer.

Best Regards,
Amelia

0 Votes 0 ·

1 Answer

ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.