This discussion is archived
2 Replies Latest reply: Jul 24, 2013 7:12 AM by user5723039 RSS

Oracle Parameters

user5723039 Newbie
Currently Being Moderated

Hello,

 

I am trying to parse the results of a select statement into a text file.

 

As I follow the instructions in Mastering Oracle + Python Series, I ran into an issue.

Here is a segment of my code:


cur.execute('SELECT FACILITYID, INSPECTIONDATE, INSPECTIONVENDOR FROM THIS.TABLE WHERE OBJECTID IN (107109, 3070, 9808, 88839)') [<cx_Oracle.STRING with value None>, <cx_Oracle.DATETIME with value None>, <cx_Oracle.STRING with value None>]

 

And here is the error I got:

 

SyntaxError: invalid syntax

D:\>D:\Python275\python.exe D:\oracle.py

  File "D:\oracle.py", line 30

    [<cx_Oracle.STRING with value None>, <cx_Oracle.DATETIME with value None>, <

cx_Oracle.STRING with value None>]

     ^

SyntaxError: invalid syntax

 

Any suggestions?

 

Thanks.

E

  • 1. Re: Oracle Parameters
    cj Employee ACE
    Currently Being Moderated

    Are you entering " [<cx_Oracle.STRING with value None>, <cx_Oracle.DATETIME with value None>, <cx_Oracle.STRING with value None>]"?  This is the output of Python, and is not something you enter.

  • 2. Re: Oracle Parameters
    user5723039 Newbie
    Currently Being Moderated

    Now I understand, I guess [<cx_Oracle.STRING with value None>, <cx_Oracle.DATETIME with value None>, <cx_Oracle.STRING with value None>] was presented as an example result set.

    After playing around with some code, I get the following output when I try to print results to a text file.

     

        

    ('H38428', datetime.datetime(1996, 8, 26, 0, 0), 'O WOOD PRESERVING, INC.')

    ('PN34237', datetime.datetime(1992, 10, 28, 0, 0), 'A TREE EXPERT CO.')

    ('MV3342', datetime.datetime(1989, 7, 27, 0, 0), 'O WOOD PRESERVING, INC.')

    ('S13127', datetime.datetime(1987, 9, 24, 0, 0), 'A TREE EXPERT CO.')

     

    This is probably a result of

    f.write(str(row))

     

    But how do i correctly format datetime.datetime ?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points