Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-637

[Python][Shard] cursor.execute() can not work with a binding shard sql query

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Python 9.2.0.0001
    • Fix Version/s: Python 9.2.0.0001
    • Component/s: Python Driver
    • Labels:
    • Environment:
      • OS: Linux 64bit, Windows 32bit
      • CUBRID: 9.2.0.0128
      • Python: 2.6.5
      • Driver: cubrid-python 9.2.0.0001 (20130813)

      Description

      • Brief: cursor.execute() can not work correctly with a bind shard sql query
      • Test Code (CUBRID shard configration - see attachments) {code}
        con = _cubrid.connect('CUBRID:10.34.64.58:36057:shard1:::', 'dba', '')
        cursor = con.cursor()

        # you need create a python_shard table on shard1 first "CREATE TABLE python_shard(id int);"
        cursor.prepare('insert into python_shard values (/*+ shard_key */ ?)')
        cursor.bind_param(1, '2')
        cursor.execute()

        cursor.prepare('insert into python_shard values (/*+ shard_key */ ?)')
        cursor.bind_param(1, '33')
        cursor.execute()

        con.close(){code}

      Expect Result:

      $ csql -u dba shard1 -c "select * from python_shard"
      
      === <Result of SELECT Command in Line 1> ===
                 id
      =============
                 2
      
      $ csql -u dba shard2 -c "select * from python_shard"
      === <Result of SELECT Command in Line 1> ===
                 id
      =============
                 33
      

      Actual Result

      ======================================================================
      ERROR: test_shard_insert_bind (__main__.pythonShard)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "python_shard.py", line 32, in test_shard_insert_bind
          cursor.execute()
      InterfaceError: (-10001, 'ERROR: CAS, -10001, Not used')
      
      1. cubrid_broker.conf
        2 kB
        Ray Yin
      2. shard_connection.txt
        0.5 kB
        Ray Yin
      3. shard_key.txt
        0.2 kB
        Ray Yin

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment -

        New feature of bind_param(index.value,bind_type): bind_type is optional.

        con = _cubrid.connect('CUBRID:10.34.64.218:36069:shard1:::', 'dba', '')
        #con =CUBRIDdb.connect('CUBRID:10.34.64.218:36069:shard1:::', 'dba', '')
        cursor = con.cursor()

        1. you need create a python_shard table on shard1 first "CREATE TABLE python_shard(id int);"
          cursor.prepare('insert into python_shard values (/*+ shard_key */ ?)')
          cursor.bind_param(1, '2',FIELD_TYPE.INT)
          cursor.execute()

        cursor.prepare('insert into python_shard values (/*+ shard_key */ ?)')
        cursor.bind_param(1, '33',FIELD_TYPE.INT)
        cursor.execute()

        con.close()

        Show
        cn15800 谢韦华[Bert] added a comment - New feature of bind_param(index.value,bind_type): bind_type is optional. con = _cubrid.connect('CUBRID:10.34.64.218:36069:shard1:::', 'dba', '') #con =CUBRIDdb.connect('CUBRID:10.34.64.218:36069:shard1:::', 'dba', '') cursor = con.cursor() you need create a python_shard table on shard1 first "CREATE TABLE python_shard(id int);" cursor.prepare('insert into python_shard values (/*+ shard_key */ ?)') cursor.bind_param(1, '2',FIELD_TYPE.INT) cursor.execute() cursor.prepare('insert into python_shard values (/*+ shard_key */ ?)') cursor.bind_param(1, '33',FIELD_TYPE.INT) cursor.execute() con.close()
        Hide
        ryin005 Ray Yin added a comment -
        • Test OS: Linux 64bit, Windows 32bit
        • CUBRID: 9.2.0.0128
        • Python: 2.6.5, 2.7.3
        • Driver: cubrid-python 9.1.0.0001 (20130815)

        Test Result: Pass

        Show
        ryin005 Ray Yin added a comment - Test OS: Linux 64bit, Windows 32bit CUBRID: 9.2.0.0128 Python: 2.6.5, 2.7.3 Driver: cubrid-python 9.1.0.0001 (20130815) Test Result: Pass
        Hide
        ryin005 Ray Yin added a comment -

        Since the bind_param() has been updated with an new feature, we should update the relevant manual (e.g. http://pythonhosted.org/CUBRID-Python/)

        The issue could be closed after the manual updated

        Show
        ryin005 Ray Yin added a comment - Since the bind_param() has been updated with an new feature, we should update the relevant manual (e.g. http://pythonhosted.org/CUBRID-Python/ ) The issue could be closed after the manual updated

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            ryin005 Ray Yin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: