Menu

#72 [Python] Fetchone get bit varying data is not correct

open
nobody
None
5
2012-02-02
2012-02-02
Jira Trac
No

# Brief:
## Insert bit data B'1' into database and use fetchone method to get the data, but the return data is not correct.
# Test Steps:
## insert a bit data B'1' into table
## select the data and check it
# Result:
## Expect result is '8'
## Actual result is '80'
# Code reference:
{noformat}
import CUBRIDdb
import unittest

class FetchoneTest(unittest.TestCase):
def test_bit(self):
self.con = CUBRIDdb.connect(CUBRID:localhost:33011:demodb, dba,)
self.cur = self.con.cursor()
sqlCreate = create table bit_db(c_bit bit varying(8))
self.cur.execute(sqlCreate)
data = 'B\'1\''
dataCheck = '8'
sqlInsert = insert into bit_db(c_bit) values ( +data +)
self.cur.execute(sqlInsert)
sqlSelect = select * from bit_db
self.cur.execute(sqlSelect)
dataReturn = self.cur.fetchone()
self.assertEquals(dataCheck, dataReturn[0])

if __name__ == '__main__':
unittest.main()
{noformat}

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.