简体   繁体   English

无法使用Azure函数将值写入数据库

[英]Failure to write values to db using Azure function

I am trying to using an Azure function to write data into an Azure SQL server. 我正在尝试使用Azure函数将数据写入Azure SQL服务器。 I 've built three pipelines successfully but failed in this one. 我已经成功构建了三个管道,但在这一过程中失败了。

I am trying to write a line to the database using: 我正在尝试使用以下方式向数据库写一行:

cursor.execute("insert into beamSetupResults values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7], val[8], val[9], val[10], val[11])

And the values are (And I print these values during decoding the response so they are guruanteed to be string): 值是(并且我在解码响应时打印这些值,因此将其保证为字符串):

['800112', '', '2016-08-08T15:11:05Z', 'pass', 'Al-13kV-3', 13, 80000, 132.0092315673828, 79936.953125, '', False, True]

I got errors as follows: 我得到如下错误:

[Error] Exception while executing function: Functions.TimeTrigger_BeamSetup. Microsoft.Azure.WebJobs.Script: TypeError: expected bytes, str found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Repos\azure-python-siteextensions\source_packages\python.3.5.2\tools\Lib\encodings\utf_16_le.py", line 16, in decode
SystemError: <built-in function utf_16_le_decode> returned a result with an error set 
ith an error set

The above exception was the direct cause of the following exception:

SystemError: decoding with 'utf-16le' codec failed (SystemError: <built-in function utf_16_le_decode> returned a result with an error set)

Moreover, I am pretty these values matches the table of my database. 而且,我很高兴这些值与数据库的表匹配。 Before I got this error, it worked for several days. 在收到此错误之前,它已经工作了好几天。 I've tested these code locally and all of them works fine. 我已经在本地测试了这些代码,并且它们都能正常工作。

I am using pyodbc package and the driver is 13. 我正在使用pyodbc软件包,驱动程序是13。

Any thoughts? 有什么想法吗? I really appreciate your help. 非常感谢您的帮助。

只需升级您的pyodbc软件包版本,一切都会好起来的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM