Menu

#308 Python CUBRIDdb driver should implement cubrid_set_autocommit/cubrid_get_autocommit

open
nobody
None
5
2012-10-05
2012-10-05
Jira Trac
No

First of all, I used the documentation from here:
http://packages.python.org/CUBRID-Python/

and I tried to use the CUBRIDdb driver.

Currently, rollback/commit functions from the driver cannot be used at all. That's why this bug is critical. It leads to various bugs because cubrid auto_commit mode cannot be enabled or disabled.

The following functions: cubrid_set_autocommit/cubrid_get_autocommit from the CCI driver should be called in the python driver also.

The _cubrid driver holds most of these functions, but it lacks others. CUBRIDdb should support these functions also.

Here is a test code:
{code}
import CUBRIDdb

con = CUBRIDdb.connect('CUBRID:localhost:33000:demodb', 'dba', '')
c = con.cursor()

c.execute(DROP TABLE IF EXISTS posts)
c.execute(CREATE TABLE posts(id integer,title varchar(255),body string,last_updated timestamp);)
args = (4, 'ddd', 'CUBRID-Python is Open Source!!')
c.execute('insert into posts(id, title, body, last_updated) values (?, ?, ?, SYSTIMESTAMP)', args)
con.rollback()

c.execute('select * from posts')
rows = c.fetchall()

for r in rows:
print r
{code}

Here is a similar task in PHP (where everything works fine):
{code}
$conn = cubrid_connect(localhost, 33000, demodb, dba, );
cubrid_set_autocommit($conn,CUBRID_AUTOCOMMIT_FALSE);

cubrid_query(DROP TABLE IF EXISTS tst);
cubrid_query(CREATE TABLE tst (a INTEGER));
cubrid_query(INSERT INTO tst VALUES(1));
cubrid_commit($conn);
cubrid_query(INSERT INTO tst VALUES(2));
cubrid_query(INSERT INTO tst VALUES(3));
cubrid_rollback($conn);

cubrid_disconnect($conn);
{code}

In the _cubrid driver there are other very useful functions such as: insert_id(), client_version(), server_version(), set_isolation_level().

I cannot use _cubrid driver as it is missing executemany() and fetchall().

Another useful function would be to get/set the charset used (I am referring to functions that exist in the CCI).

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.