CS_CONTEXT structure
internally for conversions and calculations. You must allocate a
context via cs_ctx_alloc() and establish the internal
context using this function.
None or an
object which has write(data) and flush() methods.
The function returns the previous debug file. The default file is
None.
Setting a debug file does not enable debug messages. To produce debug messages you need to set the debug member of a context, connection, command, etc.
= CS_VERSION_100])
result = cs_ctx_alloc(version, &ctx);
Returns a tuple containing the Sybase result code and a new instance
of the CS_CONTEXT class constructed from the ctx value
returned by cs_ctx_alloc(). None is returned as the
CS_CONTEXT object if the result code is not CS_SUCCEED.
= CS_VERSION_100])
result = cs_ctx_global(version, &ctx);
Returns a tuple containing the Sybase result code and a new instance
of the CS_CONTEXT class constructed from the ctx value
returned by cs_ctx_global(). None is returned as the
CS_CONTEXT object if the result code is not CS_SUCCEED.
For all types of obj other than CS_DATAFMT a buffer will be initialised which contains a single value.
When obj is a CS_DATAFMT object an empty buffer will be created according to the attributes of the CS_DATAFMT object. It is most common to create and bind a buffer in a single operation via the ct_bind() method of the CS_COMMAND class.
For example, the following code creates a set of buffers for retrieving 16 rows at a time. Note that it is your responsibility to ensure that the buffers are not released until they are no longer required.
status, num_cols = cmd.ct_res_info(CS_NUMDATA)
if status != CS_SUCCEED:
raise 'ct_res_info'
bufs = []
for i in range(num_cols):
status, fmt = cmd.ct_describe(i + 1)
if status != CS_SUCCEED:
raise 'ct_describe'
fmt.count = 16
status, buf = cmd.ct_bind(i + 1, fmt)
if status != CS_SUCCEED:
raise 'ct_bind'
bufs.append(buf)
= -1][, scale = -1])
The obj argument can accept any of the following types;
IntType, LongType, FloatType, StringType,
or NumericType.
If greater than or equal to zero the precision and scale
arguments are used as the precision and scale
attributes of the CS_DATAFMT which is used in the Sybase
cs_convert() function to create the new NumericType
object. The default values for these arguments depends upon the type
being converted to NumericType.
| Type | precision | scale |
IntType |
16 |
0 |
LongType |
# of digits in str() conversion |
0 |
FloatType |
CS_MAX_PREC |
12 |
StringType |
# digits before decimal point | # digits after decimal point |
NumericType |
input precision | input scale |
= CS_MONEY_TYPE])
The obj argument can accept any of the following types;
IntType, LongType, FloatType, StringType,
or MoneyType.
Passing CS_MONEY4_TYPE in the type argument will create a
smallmoney value instead of the default money.
= CS_DATETIME_TYPE])
The str argument must be a string.
Passing CS_DATETIME4_TYPE in the type argument will
create a smalldatetime value instead of the default
datetime.
The values expected for the type_code argument things like;
CS_CHAR_TYPE, CS_TINYINT_TYPE, etc.
CS_DATAFMT structure.
CS_IODESC structure.
CS_LAYER macro to the
msgnumber argument.
CS_ORIGIN macro to the
msgnumber argument.
CS_SEVERITY macro to the
msgnumber argument.
CS_NUMBER macro to the
msgnumber argument.