type a select results from oracle database

Asked by Laanaya doha

Hello, so here is my problem i want to type a select result from my database in my application but i got a weird error and my print the result of the query i don't get it right . here is my script and the error :

MY script :
db=zxJDBC.connect("jdbc:oracle:thin:@10.1.0.99:1521:ORCL","AGRO01", "AGRO01","oracle.jdbc.driver.OracleDriver", CHARSET='iso_1')
    c = db.cursor()
    c.execute("select code from fournisseur where code<'451256'")
    row=c.fetchone()
    print(row)
    click("1397814484205.png")//my image contains a an input text where i want to type the result that i get in row
    type('row',KeyModifier.WIN)

and here is what i got :
[(u'451256',)]// this is the result of the query but i just want the number 451256 i don't know why it gives me the result like this

[log] CLICK on L(223,213)@S(0)[0,0 1920x1080]

[error] script [ test ] stopped with error in line 12
[error] TypeError ( type(): 1st arg can't be coerced to String )

is there anything that can be done , please help me thank you

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Laanaya doha
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Apparently the c.fetchone() returns a list containing tuples of unicode strings.

I guess you have to know this based on the structure of your db record.

To get the number as string ready for type():
number = row[0][0]
type(number, KeyModifier.WIN)

type('row', ...) is not correct anyway - might be a typo (since this would not produce the error message)

Revision history for this message
Laanaya doha (dlaanaya) said :
#2

hi i tried what you give me as a solution but unfortunately it gives 0 and not what i have in my database .
just to know the type of variables that i want to get from the column is varchar(2), i don't know if this is the problem, but i really tried a lot of things but it doesn't work

Revision history for this message
Laanaya doha (dlaanaya) said :
#3

after all you're solution did help me , is solved my problem by working with paste() and not type() :
here is my solution :
    c = db.cursor(0)
    c.execute("select code from fournisseur where code<'451256'")
    row=c.next()
    number=row[0]
    print(row)
    print(number)
    paste("1397814484205.png",number)
and it works thank you for you're help