Trees | Indices | Help |
---|
|
object --+ | cursor
Cursor class.
|
|||
|
|||
a new object with type S, a subtype of T |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
description description |
|||
rowcount row count |
|||
Inherited from |
|
x.__init__(...) initializes x; see help(type(x)) for signature
|
|
repr(x)
|
Only used internally. This function should not be used by user. |
get the number of rows affected by the SQL sentence (INSERT, DELETE, UPDATE). Return values: Success: Number of rows affected by the SQL sentence Failure: -1 |
bind BLOB/CLOB type in prepare() variable. Parameters: index: string, actual value for binding lob: LOB Object Example: import _cubrid con = _cubrid.connect('CUBRID:localhost:33000:demodb:::', 'public') cur = con.cursor() cur.prepare('create table test_blob(image BLOB)') cur.execute() cur.prepare('create table test_clob(image CLOB)') cur.execute() lob = con.lob() cur.prepare('insert into test_blob values (?)') lob.imports('123.jpg') # or lob.imports('123.jpg', 'B') cur.bind_lob(1, lob) cur.execute() lob.close() cur.prepare('insert into test_clob values (?)') lob.imports('123.jpg', 'C') cur.bind_lob(1, lob) cur.execute() lob.close() cur.close() con.close() |
This function is used to bind values in prepare() variable. You can pass any type as string, except BLOB/CLOB type. In CUBRID shard envrioment, the bind_type must be included in the bind_param function. The following shows the types of substitute values: CHAR STRING NCHAR VARCHAR NCHAR VARYING BIT BIT VARYING SHORT INT NUMERIC FLOAT DOUBLE TIME DATE TIMESTAMP OBJECT BLOB CLOB NULL Parameters: index: int, index for binding value: string, actual value for binding bind_type(optional):column type of database |
bind_set LIST/SET/MULTISET data. To use this function. index:actual value for binding data:tuple object Example:: con = _cubrid.connect('CUBRID:localhost:30000:demodb:dba::') c = con.cursor() s = con.set() value = ('1','2') s.imports(value ,CUBRIDdb.CCI_U_TYPE_INT) c.prepare('''INSERT INTO set_tbl_int VALUES(?);''') c.bind_set(1,s) c.execute() con.commit() c.close() con.close() |
move the cursor based on the original position. offset: int, number of units you want to move the cursor. |
Executes a prepared Query. A option can be used when retrieving the query result from the server. A option can be classified as synchronous or asynchronous. If the option is set to CUBRID_EXEC_QUERY_ALL, a synchronous mode(sync_mode) is used to retrieve query results immediately after executing prepared queries. If it is set to CUBRID_EXEC_ASYNC, an asynchronous mode (async_mode) is used to retrieve the result immediately each time a query result is created. The option is set to CUBRID_EXEC_QUERY_ALL by default, and in such cases the following rules are applied:
max_col is a value that is used to determine the size of the column to be transferred to the client when the type of the column of the prepared query is CHAR, VARCHAR, NCHAR, VARNCHAR, BIT or VARBIT. If it is set to 0, all data is transferred. Parameters: option: Exec option, option maybe the following values: CUBRID_EXEC_ASYNC CUBRID_EXEC_QUERY_ALL CUBRID_EXEC_QUERY_INFO CUBRID_EXEC_ONLY_QUERY_PLAN CUBRID_EXEC_THREAD Return values: SELECT: Returns the number of results in sync mode, returns 0 in asynchronism mode. INSERT, UPDATE: Returns the number of tuples reflected. Others queries: 0 |
get BLOB/CLOB data out from the database server. You need to specify which column is lob type. Parameters: col: int, the column of LOB lob: LOB object, to process LOB data. Example: import _cubrid con = _cubrid.connect('CUBRID:localhost:33000:demodb:::', 'public') cur = con.cursor() cur.prepare('select * from test_lob') cur.execute() lob = con.lob() cur.fetch_lob(1, lob) lob.close() cur.close() con.close() |
get a single row from the query result. The cursor automatically moves to the next row after getting the result. Example: import _cubrid con = _cubrid.connect('CUBRID:localhost:33000:demodb:::', 'public') cur = con.cursor() cur.prepare('select * from test_cubrid') cur.execute() row = cur.fetch_row() while row: print row row = cur.fetch_row() cur.close() con.close() |
get results of next query if CUBRID_EXEC_QUERY_ALL flag is set upon execute(). If next result is executed successfully, the database is updated with the information of the current query. |
get the number of columns from the query result. It can only be used when the query executed is a select sentence. |
get the number of rows from the query result. It can only be used when the query executed is a select sentence. |
This function creates a prepared statement. A prepared statement is a server-side object that can be used to optimize performance. You can use this statement effectively to execute repeatedly or to process long data. Only a single statement can be used. The SQL statement can contain zero or more question mark (?) parameter markers for which real values will be substituted when the statement is executed. Add a parameter when you bind a value in the VALUES clause of INSERT statement or in the WHERE clause. sql: string, the sql statement you want to execute. |
returns a sequence of 15-item sequences. Each of these sequence contails information describing one result column: (datatype, scale, precision, col_name, attr_name, class_name, not_null, default_value, auto_increment, unique_key, primary_key, foreign_key, reverse_index, reverse_unique, shared) values of datatype will map the following: char 1 string,varchar 2 nchar 3 varnchar 4 bit 5 varbit 6 numeric 7 int 8 short 9 monetary 10 float 11 double 12 date 13 time 14 timestamp 15 object 19 set 32 multiset 64 sequence 96 This function will return none if there is no result set. If user not specifies the parameter row, it will return all column's information. If user specify row, it will return the specified column's information. row: int, the column you want to get the information. Example: import _cubrid con = _cubrid.connect('CUBRID:localhost:33000:demodb:::', 'public') cur = con.cursor() cur.prepare('select * from test_cubrid') cur.execute() infos = cur.result_info() for info in infos: print info print cur.result_info(1) cur.close() con.close() |
move the current cursor based on current cursor position. If give a positive number, it will move forward. If you give a negative number, it will move back. offset: int, relative location that you want to move. |
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Mar 28 11:44:57 2014 | http://epydoc.sourceforge.net |