Python connection gbase 8 a MPP
# coding: utf-8
The from GBaseConnector import connect, GBaseError
The import struct
Def foo (res) :
For n in res:
The yield of n, vsum
If __name__=="__main__ ':
The config={' host ':' 192.168.1.5 ',
'user' : 'root',
'password' : ' ',
'the port: 5258}
Try:
Conn=the connect ()
Conn. Connect (* * config)
Cur=conn. Cursor ()
# cur. Execute (" the create DATABASE if the exists testpython ")
Cur. Execute (" use tt ")
# cur. Execute (" create table x1 (id1 int, id2 int, id3 int, id4 int) ")
# cur. Execute (" insert into the x1 values (1, 2, 3, 4) ")
Cur. Execute (" select * from the test limit 100000000000 ")
Res=cur. Fetchall ()
Print (" row length is % d % "len (res))
Vsum=0
Gg=foo (res)
Next (gg)
For I in range (len (res) :
Gg. Send (I)
Print (' total='vsum)
Except GBaseError. DatabaseError as err:
Print (err)
Finally:
Conn. Close ()
Cur. Close ()
Res=None