sqlmlutils
sqlmlutils copied to clipboard
sqlmlutils fail to install packages on SQL Server 2022
Got python to work, but installing packages throws this error.
As a FYI - I could not get sqlmlutils to work on 2019. It would look like it install, but the python package would fail to load properly. Pip Install worked on 2019.
Given the location of Python is different on 2022 to 2019, is it possible to use Pip Install on 2022??
sqlmlutils CALL
import sqlmlutils connection = sqlmlutils.ConnectionInfo(server="xx\xx", uid="sa", pwd="xxx") sqlmlutils.SQLPackageManager(connection).install("QuantLib")
FULL ERROR
ProgrammingError Traceback (most recent call last) File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\sqlqueryexecutor.py:67, in SQLQueryExecutor.execute_query(self, query, params, out_file) 66 if params is not None: ---> 67 self._cursor.execute(query, params) 68 else:
ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004. External script request id is CD35FDA4-7E2E-425F-B013-8BD4D069AC74. (39004) (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]An external script error occurred: \n\r\nError in execution. Check the output for more information.\r (39019)")
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last) Cell In [1], line 3 1 import sqlmlutils 2 connection = sqlmlutils.ConnectionInfo(server="xx\xx", uid="sa", pwd="xxx") ----> 3 sqlmlutils.SQLPackageManager(connection).install("QuantLib")
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\packagemanagement\sqlpackagemanager.py:78, in SQLPackageManager.install(self, package, upgrade, version, install_dependencies, scope, out_file) 76 self._install_from_file(package, scope, upgrade, out_file=out_file) 77 else: ---> 78 self._install_from_pypi(package, upgrade, version, install_dependencies, scope, out_file=out_file)
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\packagemanagement\sqlpackagemanager.py:158, in SQLPackageManager._install_from_pypi(self, target_package, upgrade, version, install_dependencies, scope, out_file) 155 target_package = target_package + "==" + version 157 with tempfile.TemporaryDirectory() as temporary_directory: --> 158 pipdownloader = PipDownloader(self._connection_info, temporary_directory, target_package, language_name = self._language_name) 159 target_package_file = pipdownloader.download_single() 160 self._install_from_file(target_package_file, scope, upgrade, out_file=out_file)
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\packagemanagement\pipdownloader.py:20, in PipDownloader.init(self, connection, downloaddir, targetpackage, language_name) 18 self._targetpackage = targetpackage 19 self._language_name = language_name ---> 20 server_info = SQLPythonExecutor(connection, self._language_name).execute_function_in_sql(servermethods.get_server_info) 21 globals().update(server_info)
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\sqlpythonexecutor.py:56, in SQLPythonExecutor.execute_function_in_sql(self, func, input_data_query, *args, **kwargs) 29 def execute_function_in_sql(self, 30 func: Callable, *args, 31 input_data_query: str = "", 32 **kwargs): 33 """Execute a function in SQL Server. 34 35 :param func: function to execute_function_in_sql. NOTE: This function is shipped to SQL as text. (...) 54 [0.28366218546322625, 0.28366218546322625] 55 """ ---> 56 df, _ = execute_query(SpeesBuilderFromFunction(func, 57 self._language_name, 58 input_data_query, 59 *args, 60 **kwargs), 61 self._connection_info) 63 results, output, error = self._get_results(df) 65 if output is not None:
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\sqlqueryexecutor.py:24, in execute_query(builder, connection, out_file) 22 def execute_query(builder, connection: ConnectionInfo, out_file:str=None): 23 with SQLQueryExecutor(connection=connection) as executor: ---> 24 return executor.execute(builder, out_file=out_file)
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\sqlqueryexecutor.py:41, in SQLQueryExecutor.execute(self, builder, out_file) 40 def execute(self, builder: SQLBuilder, out_file=None): ---> 41 return self.execute_query(builder.base_script, builder.params, out_file=out_file)
File ~\azuredatastudio-python\lib\site-packages\sqlmlutils\sqlqueryexecutor.py:96, in SQLQueryExecutor.execute_query(self, query, params, out_file) 93 continue 95 except Exception as e: ---> 96 raise RuntimeError("Error in SQL Execution: " + str(e)) 98 return df, output_params
RuntimeError: Error in SQL Execution: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]A 'Python' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004. External script request id is CD35FDA4-7E2E-425F-B013-8BD4D069AC74. (39004) (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]An external script error occurred: \n\r\nError in execution. Check the output for more information.\r (39019)")