Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python崩溃时使用了";字符串数据,右截断“;在Sybase表插入中使用fast_executemany=True时_Python_Sybase - Fatal编程技术网

Python崩溃时使用了";字符串数据,右截断“;在Sybase表插入中使用fast_executemany=True时

Python崩溃时使用了";字符串数据,右截断“;在Sybase表插入中使用fast_executemany=True时,python,sybase,Python,Sybase,我正在使用下面的函数插入包含大量数据的Sybase表。我使用fast_executemany=True,因为没有它,性能会非常慢,无法满足我的要求。下面的代码给出了上述表格的错误信息。这是一个通用函数,它将数据帧和插入作为输入传递给函数的目标表。我不能定制特定于表的表,因为表的结构因表而异 作用 我的连接字符串是 self.cnxn = pyodbc.connect('DRIVER={Adaptive Server Enterprise};uid=' + self.user +';Encrypt

我正在使用下面的函数插入包含大量数据的Sybase表。我使用fast_executemany=True,因为没有它,性能会非常慢,无法满足我的要求。下面的代码给出了上述表格的错误信息。这是一个通用函数,它将数据帧和插入作为输入传递给函数的目标表。我不能定制特定于表的表,因为表的结构因表而异

作用 我的连接字符串是

self.cnxn = pyodbc.connect('DRIVER={Adaptive Server Enterprise};uid=' + self.user +';EncryptPassword=1;pwd=' + self.password + ';Port=' + self.dbport + ';Server=' + self.server +';Database=' + dbname)

下面是它失败的表结构,错误为
**pyodbc.ProgrammingError:('String data,right truncation:length 22 buffer 20','HY000')**


我也尝试了以下方法,但没有解决此问题

cursor.setinputsizes(
    [
        (pyodbc.SQL_VARCHAR,500,1000),
        (pyodbc.SQL_INTEGER),
        (pyodbc.SQL_FLOAT),
    ]
)
目标表 由于这是一个通用函数,请让我知道代码的问题是什么,以及我上面提到的表失败的原因


带误差的实际输出 下面是实际错误的输出

[<class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'str'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'datetime.datetime'>, <class 'str'>, <class 'int'>]
Traceback (most recent call last):
  File "ODBCTableCopy.py", line 121, in <module>
    out.append(_table_copy_(targetTable=target_table, sourceObject=sql, source=source, target=target, database=Database , loadType=load_type))
  File "ODBCTableCopy.py", line 67, in _table_copy_
    _sybase_insert(source_df,targetTable, loadType, target, database)
  File "ODBCTableCopy.py", line 47, in _sybase_insert
    cursor.executemany(sql, rows)
pyodbc.ProgrammingError: ('String data, right truncation: length 22 buffer 20', 'HY000')
[,,,,,,,,,]
回溯(最近一次呼叫最后一次):
文件“ODBCTableCopy.py”,第121行,在
append(_table_copy_(targetTable=target_table,sourceObject=sql,source=source,target=target,database=database,loadType=load_type))
文件“ODBCTableCopy.py”,第67行,在表副本中_
_sybase_insert(源文件、目标文件、加载类型、目标文件、数据库)
文件“ODBCTableCopy.py”,第47行,插入
cursor.executemany(sql,行)
pyodbc.ProgrammingError:(“字符串数据,右截断:长度22缓冲区20”,“HY000”)
COLUMN_NAME      DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX IS_NULLABLE 
---------------- --------- --------- ----------- ------------- -------------- -------------- ----------- 
Column1          4         int       10          10            0              10             NO          
Column2          4         int       10          10            0              10             NO          
Column3          4         int       10          10            0              10             NO          
Column4          4         int       10          10            0              10             NO          
Column5          4         int       10          10            0              10             NO          
column6          4         int       10          10            0              10             NO          
column7          4         int       10          10            0              10             NO          
column8          1         char      12          12            (null)         (null)         NO          
column9          1         char      12          12            (null)         (null)         NO          
column10         4         int       10          10            0              10             NO          
column11         4         int       10          10            0              10             NO          
column12         1         char      12          12            (null)         (null)         NO          
column13         4         int       10          10            0              10             NO          
column14         4         int       10          10            0              10             NO          
column15         4         int       10          10            0              10             NO          
column16         4         int       10          10            0              10             NO          
column17         1         char      30          30            (null)         (null)         NO          
column18         4         int       10          10            0              10             NO          
column19         4         int       10          10            0              10             NO          
column20         4         int       10          10            0              10             NO          
column21         93        datetime  23          23            3              10             NO          
column22         1         char      10          10            (null)         (null)         NO          
column23         4         int       10          10            0              10             NO          
    
[<class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'str'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'str'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'datetime.datetime'>, <class 'str'>, <class 'int'>]
Traceback (most recent call last):
  File "ODBCTableCopy.py", line 121, in <module>
    out.append(_table_copy_(targetTable=target_table, sourceObject=sql, source=source, target=target, database=Database , loadType=load_type))
  File "ODBCTableCopy.py", line 67, in _table_copy_
    _sybase_insert(source_df,targetTable, loadType, target, database)
  File "ODBCTableCopy.py", line 47, in _sybase_insert
    cursor.executemany(sql, rows)
pyodbc.ProgrammingError: ('String data, right truncation: length 22 buffer 20', 'HY000')