小编Ani*_*Dey的帖子

sql 中的 HASHBYTES、sha2_256 在从 python 调用时引入坏字符

我们的旧 sql 遗留代码之一,使用 HASHBYTES 函数和 sha2_256 转换 sql 中的数字列。

整个过程正在转移到 python,因为我们在遗留工作之上加入了一些高级用法。但是,在使用连接器时,我们调用了相同的 sql 代码,即 HASHBYTES('sha2_256',column_name) id 返回带有大量垃圾的值。

在 sql 中运行代码导致此

Column      Encoded_Column
101286297   0x7AC82B2779116F40A8CEA0D85BE4AA02AF7F813B5383BAC60D5E71B7BDB9F705
Run Code Online (Sandbox Code Playgroud)

从 python 运行相同的 sql 查询结果

Column      Encoded_Column
101286297 
Run Code Online (Sandbox Code Playgroud)

b"z\xc8+'y\x11o@\xa8\xce\xa0\xd8[\xe4\xaa\x02\xaf\x7f\x81;S\x83\xba\xc6\r^q\xb7\xbd\xb9\ xf7\x05"

代码是

Select Column,HASHBYTES('SHA2_256', CONVERT(VARBINARY(8),Column)) as Encoded_Column from table
Run Code Online (Sandbox Code Playgroud)

我尝试过通常的垃圾清除,但没有帮助

python sql connector pandas hashbytes

3
推荐指数
1
解决办法
298
查看次数

需要了解通过 REST API 在 Azure 中运行命令

我正在关注此文档并尝试使用它在 vm 中运行一个简单的 shell 脚本。

https://docs.microsoft.com/en-us/rest/api/compute/virtual%20machines%20run%20commands/runco​​mmand#runco​​mmandinputparameter

但是post请求的body需要什么内容就不清楚了。commandID 可以是 RunShellScript 但我们在哪里提供脚本值。

我试过这样的身体

{
    commandId: "RunShellScript",
        script: "/path/scriptname"
}
Run Code Online (Sandbox Code Playgroud)

有其他选择

script: 'scriptname'
script: 'sh scriptname'
Run Code Online (Sandbox Code Playgroud)

和其他每个导致

{
"error": {
"code": "BadRequest",
"message": "Error converting value "/home/admin1/quick-python-test.sh" to type 'System.Collections.Generic.List`1[System.String]'. Path 'script', line 3, position 52.",
"target": "runCommandInput.script"
}
}
Run Code Online (Sandbox Code Playgroud)

谁能帮助我如何正确地做到这一点?我是 Azure 的新手。

azure azure-virtual-machine azure-rest-api

0
推荐指数
1
解决办法
1242
查看次数