Details
-
Type:
New Feature
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: Python-Aprium, Python-8.4.1 p1
-
Component/s: Python Driver
-
Labels:None
-
Environment:
Any
Description
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:
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
Here is a similar task in PHP (where everything works fine):
$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);
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).

Hi, Veliscu Ovidiu
In the Python Database API Specification v2.0(http://www.python.org/dev/peps/pep-0249/), the autocommit should be initially off.
Note that if the database supports an auto-commit feature, this must be initially off.
But in Cubrid(8.4.1), the autocommit is ON in default. Considered the compatiblity, we should keep the default autocommit value when user invokes the connect(). If user want to disable the autocommit, the set_autocommit(False) should be invoked. Do you think so?