【问题标题】:[SQL Server]Unclosed quotation mark after the character string ''[SQL Server]字符串''后的非右引号
【发布时间】:2021-02-04 14:34:33
【问题描述】:

我有以下数据元素

 "In less than two minutes you can provide feedback to help us build the best customer service in healthcare.",
  "Based on your chat, how easy is your health plan to do business with?", "☹️", "????", "????", "???? ", "????", "The survey has expired. Thank you for your time."

它会抛出错误

Unclosed quotation mark after the character string ''.

在 sql server 中,我将记录集设置为 nvarchar 来处理表情符号。我是否还需要将 N 附加到它?这是我的代码

    def __insert_records(self, rows, target_fields):
        try:      
            mssql_connection = BaseHook.get_connection(self.mssql_conn_id)

            connection = pyodbc.connect(DRIVER='FreeTDS',host=mssql_connection.host,DATABASE=mssql_connection.schema,user=mssql_connection.login,password=mssql_connection.password,port=mssql_connection.port,driver='/usr/lib64/etc')
            cursor = connection.cursor()

            for i, row in enumerate(rows, 1):
                record = []

                for cell in row:
                    record.append(self._serialize_cell(cell))

                record_dictionary = self.__get_record_dictionary(record, target_fields)

                cursor.execute(self.__generate_insert_sql_statement(record_dictionary))

                connection.commit()

            cursor.close()
            connection.close()
        except pyodbc.ProgrammingError as programmingError:
            sqlstate = programmingError.args[0]
            if sqlstate = '42000':
                print(programmingError.args[0])

【问题讨论】:

标签: python sql-server pyodbc


【解决方案1】:

https://github.com/FreeTDS/freetds/issues/317

我正在使用的 FreeTDS 驱动程序存在问题。正在尝试更新 mssql 驱动程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-12
    • 1970-01-01
    • 1970-01-01
    • 2013-06-05
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多