当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_ssize_t方法代码示例

本文整理汇总了Python中ctypes.c_ssize_t方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_ssize_t方法的具体用法?Python ctypes.c_ssize_t怎么用?Python ctypes.c_ssize_t使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_ssize_t方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _NumOfRows

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _NumOfRows(self):
        """Get the number of rows"""
        if not self.connection:
            self.close()
            
        NOR = c_ssize_t()
        ret = SQLRowCount(self.stmt_h, ADDR(NOR))
        if ret != SQL_SUCCESS:
            check_success(self, ret)
        self.rowcount = NOR.value
        return self.rowcount 
开发者ID:harryliu,项目名称:edwin,代码行数:13,代码来源:pypyodbc.py

示例2: capture_dunder

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def capture_dunder(cls, magic):
    """
    Makes dunder method of builtin type available to be defined by a Python
    function.
    """
    name = DUNDER_CATEGORIES.get(magic, magic)
    offset = dunder_offsets[name]
    ref_from_address = ctypes.c_ssize_t.from_address
    tp_func_ref = ref_from_address(id(Object) + offset)
    tp_func_new = ref_from_address(id(cls) + offset)
    tp_func_new.value = tp_func_ref.value 
开发者ID:fabiommendes,项目名称:sidekick,代码行数:13,代码来源:evil.py

示例3: _CreateColBuf

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _CreateColBuf(self):
        self._free_stmt(SQL_UNBIND)
        NOC = self._NumOfCols()
        self._ColBufferList = []
        for col_num in range(NOC):
            col_name = self.description[col_num][0]            
            
            col_sql_data_type = self._ColTypeCodeList[col_num]            

            # set default size base on the column's sql data type
            total_buf_len = SQL_data_type_dict[col_sql_data_type][4] 
            # over-write if there's preset size value for "large columns"
            if total_buf_len >= 20500: 
                total_buf_len = self._outputsize.get(None,total_buf_len)
            # over-write if there's preset size value for the "col_num" column 
            total_buf_len = self._outputsize.get(col_num, total_buf_len)


            alloc_buffer = SQL_data_type_dict[col_sql_data_type][3](total_buf_len)

            used_buf_len = c_ssize_t()
            
            target_type = SQL_data_type_dict[col_sql_data_type][2]
            force_unicode = self.connection.unicode_results
    
            if force_unicode and col_sql_data_type in (SQL_CHAR,SQL_VARCHAR,SQL_LONGVARCHAR):
                target_type = SQL_C_WCHAR
                alloc_buffer = create_buffer_u(total_buf_len)
            
            buf_cvt_func = self.connection.output_converter[self._ColTypeCodeList[col_num]]
            ADDR(alloc_buffer)
            ADDR(used_buf_len)
            self._ColBufferList.append([col_name, target_type, used_buf_len, ADDR(used_buf_len), alloc_buffer, ADDR(alloc_buffer), total_buf_len, buf_cvt_func]) 
开发者ID:uwdata,项目名称:termite-visualizations,代码行数:35,代码来源:pypyodbc.py

示例4: _NumOfRows

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _NumOfRows(self):
        """Get the number of rows"""
        NOR = c_ssize_t()
        ret = SQLRowCount(self.stmt_h, ADDR(NOR))
        if ret != SQL_SUCCESS:
            check_success(self, ret)
        self.rowcount = NOR.value
        return self.rowcount 
开发者ID:uwdata,项目名称:termite-visualizations,代码行数:10,代码来源:pypyodbc.py

示例5: _to_ssize_tuple

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _to_ssize_tuple(self, addr):
        from ctypes import cast, POINTER, c_ssize_t

        if addr is None:
            return None
        return tuple(cast(addr, POINTER(c_ssize_t))[0:self._view.ndim]) 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:8,代码来源:buftools.py

示例6: _CreateColBuf

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _CreateColBuf(self):
        if not self.connection:
            self.close()
        self._free_stmt(SQL_UNBIND)
        NOC = self._NumOfCols()
        self._ColBufferList = []
        bind_data = True
        for col_num in range(NOC):
            col_name = self.description[col_num][0]             
            col_size = self.description[col_num][2]     
            col_sql_data_type = self._ColTypeCodeList[col_num]  

            target_type = SQL_data_type_dict[col_sql_data_type][2]
            dynamic_length = SQL_data_type_dict[col_sql_data_type][5] 
            # set default size base on the column's sql data type
            total_buf_len = SQL_data_type_dict[col_sql_data_type][4] 
            
            # over-write if there's pre-set size value for "large columns"
            if total_buf_len > 20500: 
                total_buf_len = self._outputsize.get(None,total_buf_len)
            # over-write if there's pre-set size value for the "col_num" column 
            total_buf_len = self._outputsize.get(col_num, total_buf_len)

            # if the size of the buffer is very long, do not bind
            # because a large buffer decrease performance, and sometimes you only get a NULL value. 
            # in that case use sqlgetdata instead.
            if col_size >= 1024:
                dynamic_length = True    

            alloc_buffer = SQL_data_type_dict[col_sql_data_type][3](total_buf_len)

            used_buf_len = c_ssize_t()
            
            force_unicode = self.connection.unicode_results
    
            if force_unicode and col_sql_data_type in (SQL_CHAR,SQL_VARCHAR,SQL_LONGVARCHAR):
                target_type = SQL_C_WCHAR
                alloc_buffer = create_buffer_u(total_buf_len)
            
            buf_cvt_func = self.connection.output_converter[self._ColTypeCodeList[col_num]]
            
            if bind_data:
                if dynamic_length:
                    bind_data = False
            self._ColBufferList.append([col_name, target_type, used_buf_len, ADDR(used_buf_len), alloc_buffer, ADDR(alloc_buffer), total_buf_len, buf_cvt_func, bind_data])     
            
            if bind_data:
                ret = ODBC_API.SQLBindCol(self.stmt_h, col_num + 1, target_type, ADDR(alloc_buffer), total_buf_len, ADDR(used_buf_len))
                if ret != SQL_SUCCESS:
                    check_success(self, ret) 
开发者ID:harryliu,项目名称:edwin,代码行数:52,代码来源:pypyodbc.py

示例7: _UpdateDesc

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _UpdateDesc(self):
        "Get the information of (name, type_code, display_size, internal_size, col_precision, scale, null_ok)"  
        if not self.connection:
            self.close()
            
        force_unicode = self.connection.unicode_results
        if force_unicode:
            Cname = create_buffer_u(1024)
        else:
            Cname = create_buffer(1024)
        
        Cname_ptr = c_short()
        Ctype_code = c_short()
        Csize = ctypes.c_size_t()
        Cdisp_size = c_ssize_t(0)
        CDecimalDigits = c_short()
        Cnull_ok = c_short()
        ColDescr = []
        self._ColTypeCodeList = []
        NOC = self._NumOfCols()
        for col in range(1, NOC+1):
            
            ret = ODBC_API.SQLColAttribute(self.stmt_h, col, SQL_DESC_DISPLAY_SIZE, ADDR(create_buffer(10)), 
                10, ADDR(c_short()),ADDR(Cdisp_size))
            if ret != SQL_SUCCESS:
                check_success(self, ret)
            
            if force_unicode:
            
                ret = ODBC_API.SQLDescribeColW(self.stmt_h, col, Cname, len(Cname), ADDR(Cname_ptr),\
                    ADDR(Ctype_code),ADDR(Csize),ADDR(CDecimalDigits), ADDR(Cnull_ok))
                if ret != SQL_SUCCESS:
                    check_success(self, ret)
            else:
                
                ret = ODBC_API.SQLDescribeCol(self.stmt_h, col, Cname, len(Cname), ADDR(Cname_ptr),\
                    ADDR(Ctype_code),ADDR(Csize),ADDR(CDecimalDigits), ADDR(Cnull_ok))
                if ret != SQL_SUCCESS:
                    check_success(self, ret)
            
            col_name = Cname.value
            if lowercase:
                col_name = col_name.lower()
            #(name, type_code, display_size, 

            ColDescr.append((col_name, SQL_data_type_dict.get(Ctype_code.value,(Ctype_code.value,))[0],Cdisp_size.value,\
                Csize.value, Csize.value,CDecimalDigits.value,Cnull_ok.value == 1 and True or False))
            self._ColTypeCodeList.append(Ctype_code.value)
        
        if len(ColDescr) > 0:
            self.description = ColDescr
            # Create the row type before fetching.
            self._row_type = self.row_type_callable(self)
        else:
            self.description = None
        self._CreateColBuf() 
开发者ID:harryliu,项目名称:edwin,代码行数:58,代码来源:pypyodbc.py

示例8: _UpdateDesc

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def _UpdateDesc(self):
        "Get the information of (name, type_code, display_size, internal_size, col_precision, scale, null_ok)"  
        force_unicode = self.connection.unicode_results
        if force_unicode:
            Cname = create_buffer_u(1024)
        else:
            Cname = create_buffer(1024)
        
        Cname_ptr = c_short()
        Ctype_code = c_short()
        Csize = ctypes.c_size_t()
        Cdisp_size = c_ssize_t(0)
        CDecimalDigits = c_short()
        Cnull_ok = c_short()
        ColDescr = []
        self._ColTypeCodeList = []
        NOC = self._NumOfCols()
        for col in range(1, NOC+1):
            
            ret = ODBC_API.SQLColAttribute(self.stmt_h, col, SQL_DESC_DISPLAY_SIZE, ADDR(create_buffer(10)), 
                10, ADDR(c_short()),ADDR(Cdisp_size))
            if ret != SQL_SUCCESS:
                check_success(self, ret)
            
            if force_unicode:
            
                ret = ODBC_API.SQLDescribeColW(self.stmt_h, col, Cname, len(Cname), ADDR(Cname_ptr),\
                    ADDR(Ctype_code),ADDR(Csize),ADDR(CDecimalDigits), ADDR(Cnull_ok))
                if ret != SQL_SUCCESS:
                    check_success(self, ret)
            else:
                
                ret = ODBC_API.SQLDescribeCol(self.stmt_h, col, Cname, len(Cname), ADDR(Cname_ptr),\
                    ADDR(Ctype_code),ADDR(Csize),ADDR(CDecimalDigits), ADDR(Cnull_ok))
                if ret != SQL_SUCCESS:
                    check_success(self, ret)
            
            col_name = Cname.value
            if lowercase:
                col_name = col_name.lower()
            #(name, type_code, display_size, 

            ColDescr.append((col_name, SQL_data_type_dict.get(Ctype_code.value,(Ctype_code.value,))[0],Cdisp_size.value,\
                Csize.value, Csize.value,CDecimalDigits.value,Cnull_ok.value == 1 and True or False))
            self._ColTypeCodeList.append(Ctype_code.value)
        
        if len(ColDescr) > 0:
            self.description = ColDescr
            # Create the row type before fetching.
            self._row_type = self.row_type_callable(self)
        else:
            self.description = None
        self._CreateColBuf() 
开发者ID:uwdata,项目名称:termite-visualizations,代码行数:55,代码来源:pypyodbc.py

示例9: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_ssize_t [as 别名]
def __init__(self,
                 shape,
                 format=None,
                 strides=None,
                 readonly=None,
                 itemsize=None):
        if format is None:
            format = 'B'
        if readonly is None:
            readonly = False
        prefix = ''
        typecode = ''
        i = 0
        if i < len(format):
            try:
                prefix = self.prefixes[format[i]]
                i += 1
            except LookupError:
                pass
        if i < len(format) and format[i] == '1':
            i += 1
        if i == len(format) - 1:
            typecode = format[i]
        if itemsize is None:
            try:
                itemsize = ctypes.sizeof(self.types[prefix + typecode])
            except KeyError:
                raise ValueError("Unknown item format '" + format + "'")
        self.readonly = bool(readonly)
        self.format = format
        self._format = ctypes.create_string_buffer(format.encode('latin_1'))
        self.ndim = len(shape)
        self.itemsize = itemsize
        self.len = reduce(operator.mul, shape, 1) * self.itemsize
        self.shape = tuple(shape)
        self._shape = (ctypes.c_ssize_t * self.ndim)(*self.shape)
        if strides is None:
            self._strides = (ctypes.c_ssize_t * self.ndim)()
            self._strides[self.ndim - 1] = itemsize
            for i in range(self.ndim - 1, 0, -1):
                self._strides[i - 1] = self.shape[i] * self._strides[i]
            self.strides = tuple(self._strides)
        elif len(strides) == self.ndim:
            self.strides = tuple(strides)
            self._strides = (ctypes.c_ssize_t * self.ndim)(*self.strides)
        else:
            raise ValueError("Mismatch in length of strides and shape")
        buflen =  max(d * abs(s) for d, s in zip(self.shape, self.strides))
        self.buflen = buflen
        self._buf = (ctypes.c_ubyte * buflen)()
        offset = sum((d - 1) * abs(s)
                     for d, s in zip(self.shape, self.strides) if s < 0)
        self.buf = ctypes.addressof(self._buf) + offset 
开发者ID:wistbean,项目名称:fxxkpython,代码行数:55,代码来源:buftools.py


注:本文中的ctypes.c_ssize_t方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。