Thread: [cx-oracle-users] expecting None or a string
Brought to you by:
atuining
From: Anurag C. <anu...@gm...> - 2011-10-24 18:31:39
|
Hi All, I am getting an error "expecting None or a string" when executing a simple SQL Query as this. query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) print query cursor.execute(query) This was working fine before and I have neither changed the code nor update cx_Oracle or Oracle version etc. Please Guide. Regards, Anurag |
From: Larry M. <lar...@gm...> - 2011-10-24 18:36:01
|
On Mon, Oct 24, 2011 at 12:31 PM, Anurag Chourasia <anu...@gm...> wrote: > Hi All, > I am getting an error "expecting None or a string" when executing a simple > SQL Query as this. > query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) > print query > cursor.execute(query) > This was working fine before and I have neither changed the code nor update > cx_Oracle or Oracle version etc. Well, what do you get when you print out the query? nrb or id probably don't have the value you think. |
From: Anurag C. <anu...@gm...> - 2011-10-24 18:39:07
|
The print returns this SELECT count(*) FROM T WHERE NBR = '1' and ID='1' Both NBR and ID are varchar in my case. This query works fine when executed directly using Oracle PL/SQL Plus Regards, Anurag On Tue, Oct 25, 2011 at 12:05 AM, Larry Martell <lar...@gm...>wrote: > On Mon, Oct 24, 2011 at 12:31 PM, Anurag Chourasia > <anu...@gm...> wrote: > > Hi All, > > I am getting an error "expecting None or a string" when executing a > simple > > SQL Query as this. > > query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) > > print query > > cursor.execute(query) > > This was working fine before and I have neither changed the code nor > update > > cx_Oracle or Oracle version etc. > > Well, what do you get when you print out the query? nrb or id probably > don't have the value you think. > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |
From: Andreas M. <and...@we...> - 2011-10-24 19:00:58
|
Hi Anurag, searching for your error message with google brought this as one of the top results. Probably it helps: http://www.velocityreviews.com/forums/t691384-problem-about-cx_oracle.html Best regards Andreas Mock From: Anurag Chourasia [mailto:anu...@gm...] Sent: Monday, October 24, 2011 8:39 PM To: cx-...@li...; lar...@gm... Subject: Re: [cx-oracle-users] expecting None or a string The print returns this SELECT count(*) FROM T WHERE NBR = '1' and ID='1' Both NBR and ID are varchar in my case. This query works fine when executed directly using Oracle PL/SQL Plus Regards, Anurag On Tue, Oct 25, 2011 at 12:05 AM, Larry Martell <lar...@gm...> wrote: On Mon, Oct 24, 2011 at 12:31 PM, Anurag Chourasia <anu...@gm...> wrote: > Hi All, > I am getting an error "expecting None or a string" when executing a simple > SQL Query as this. > query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) > print query > cursor.execute(query) > This was working fine before and I have neither changed the code nor update > cx_Oracle or Oracle version etc. Well, what do you get when you print out the query? nrb or id probably don't have the value you think. ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ cx-oracle-users mailing list cx-...@li... https://lists.sourceforge.net/lists/listinfo/cx-oracle-users |
From: Anurag C. <anu...@gm...> - 2011-10-24 19:11:12
|
Thanks for the response Andreas but I am already passing string type objects in the substitution variables. This is really strange as this was working fine before and works fine from most places.. On Tue, Oct 25, 2011 at 12:30 AM, Andreas Mock <and...@we...> wrote: > Hi Anurag,**** > > ** ** > > searching for your error message with google brought this**** > > as one of the top results. Probably it helps:**** > > http://www.velocityreviews.com/forums/t691384-problem-about-cx_oracle.html > **** > > ** ** > > Best regards**** > > Andreas Mock**** > > ** ** > > ** ** > > *From:* Anurag Chourasia [mailto:anu...@gm...] > *Sent:* Monday, October 24, 2011 8:39 PM > *To:* cx-...@li...; lar...@gm... > *Subject:* Re: [cx-oracle-users] expecting None or a string**** > > ** ** > > The print returns this**** > > ** ** > > SELECT count(*) FROM T WHERE NBR = '1' and ID='1'**** > > ** ** > > Both NBR and ID are varchar in my case.**** > > ** ** > > This query works fine when executed directly using Oracle PL/SQL Plus**** > > ** ** > > Regards,**** > > Anurag**** > > ** ** > > On Tue, Oct 25, 2011 at 12:05 AM, Larry Martell <lar...@gm...> > wrote:**** > > On Mon, Oct 24, 2011 at 12:31 PM, Anurag Chourasia > <anu...@gm...> wrote: > > Hi All, > > I am getting an error "expecting None or a string" when executing a > simple > > SQL Query as this. > > query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) > > print query > > cursor.execute(query) > > This was working fine before and I have neither changed the code nor > update > > cx_Oracle or Oracle version etc.**** > > Well, what do you get when you print out the query? nrb or id probably > don't have the value you think. > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users**** > > ** ** > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |
From: Anurag C. <anu...@gm...> - 2011-10-24 19:18:37
|
Actually, upon reading the link sent by Andres further, I could make it to work by changing cursor.execute(query) to cursor.execute(str(query)) Regards, Anurag On Tue, Oct 25, 2011 at 12:40 AM, Anurag Chourasia < anu...@gm...> wrote: > Thanks for the response Andreas but I am already passing string type > objects in the substitution variables. > > This is really strange as this was working fine before and works fine from > most places.. > > > On Tue, Oct 25, 2011 at 12:30 AM, Andreas Mock <and...@we...>wrote: > >> Hi Anurag,**** >> >> ** ** >> >> searching for your error message with google brought this**** >> >> as one of the top results. Probably it helps:**** >> >> http://www.velocityreviews.com/forums/t691384-problem-about-cx_oracle.html >> **** >> >> ** ** >> >> Best regards**** >> >> Andreas Mock**** >> >> ** ** >> >> ** ** >> >> *From:* Anurag Chourasia [mailto:anu...@gm...] >> *Sent:* Monday, October 24, 2011 8:39 PM >> *To:* cx-...@li...; lar...@gm... >> *Subject:* Re: [cx-oracle-users] expecting None or a string**** >> >> ** ** >> >> The print returns this**** >> >> ** ** >> >> SELECT count(*) FROM T WHERE NBR = '1' and ID='1'**** >> >> ** ** >> >> Both NBR and ID are varchar in my case.**** >> >> ** ** >> >> This query works fine when executed directly using Oracle PL/SQL Plus**** >> >> ** ** >> >> Regards,**** >> >> Anurag**** >> >> ** ** >> >> On Tue, Oct 25, 2011 at 12:05 AM, Larry Martell <lar...@gm...> >> wrote:**** >> >> On Mon, Oct 24, 2011 at 12:31 PM, Anurag Chourasia >> <anu...@gm...> wrote: >> > Hi All, >> > I am getting an error "expecting None or a string" when executing a >> simple >> > SQL Query as this. >> > query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) >> > print query >> > cursor.execute(query) >> > This was working fine before and I have neither changed the code nor >> update >> > cx_Oracle or Oracle version etc.**** >> >> Well, what do you get when you print out the query? nrb or id probably >> don't have the value you think. >> >> >> ------------------------------------------------------------------------------ >> The demand for IT networking professionals continues to grow, and the >> demand for specialized networking skills is growing even more rapidly. >> Take a complimentary Learning@Cisco Self-Assessment and learn >> about Cisco certifications, training, and career opportunities. >> http://p.sf.net/sfu/cisco-dev2dev >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users**** >> >> ** ** >> >> >> ------------------------------------------------------------------------------ >> The demand for IT networking professionals continues to grow, and the >> demand for specialized networking skills is growing even more rapidly. >> Take a complimentary Learning@Cisco Self-Assessment and learn >> about Cisco certifications, training, and career opportunities. >> http://p.sf.net/sfu/cisco-dev2dev >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> >> > |
From: Anthony T. <ant...@gm...> - 2011-10-25 01:58:17
|
If that is the case, let me suggest that you were using Unicode without meaning to. You can also upgrade to 5.1 which allows you to pass Unicode as query strings. Anthony On Mon, Oct 24, 2011 at 1:18 PM, Anurag Chourasia <anu...@gm...> wrote: > Actually, upon reading the link sent by Andres further, I could make it to > work by changing > cursor.execute(query) > to > cursor.execute(str(query)) > > Regards, > Anurag > > On Tue, Oct 25, 2011 at 12:40 AM, Anurag Chourasia > <anu...@gm...> wrote: >> >> Thanks for the response Andreas but I am already passing string type >> objects in the substitution variables. >> This is really strange as this was working fine before and works fine from >> most places.. >> >> On Tue, Oct 25, 2011 at 12:30 AM, Andreas Mock <and...@we...> >> wrote: >>> >>> Hi Anurag, >>> >>> >>> >>> searching for your error message with google brought this >>> >>> as one of the top results. Probably it helps: >>> >>> >>> http://www.velocityreviews.com/forums/t691384-problem-about-cx_oracle.html >>> >>> >>> >>> Best regards >>> >>> Andreas Mock >>> >>> >>> >>> >>> >>> From: Anurag Chourasia [mailto:anu...@gm...] >>> Sent: Monday, October 24, 2011 8:39 PM >>> To: cx-...@li...; lar...@gm... >>> Subject: Re: [cx-oracle-users] expecting None or a string >>> >>> >>> >>> The print returns this >>> >>> >>> >>> SELECT count(*) FROM T WHERE NBR = '1' and ID='1' >>> >>> >>> >>> Both NBR and ID are varchar in my case. >>> >>> >>> >>> This query works fine when executed directly using Oracle PL/SQL Plus >>> >>> >>> >>> Regards, >>> >>> Anurag >>> >>> >>> >>> On Tue, Oct 25, 2011 at 12:05 AM, Larry Martell <lar...@gm...> >>> wrote: >>> >>> On Mon, Oct 24, 2011 at 12:31 PM, Anurag Chourasia >>> <anu...@gm...> wrote: >>> > Hi All, >>> > I am getting an error "expecting None or a string" when executing a >>> > simple >>> > SQL Query as this. >>> > query = "SELECT count(*) FROM T WHERE NBR = '%s' and ID='%s'" %(nbr,id) >>> > print query >>> > cursor.execute(query) >>> > This was working fine before and I have neither changed the code nor >>> > update >>> > cx_Oracle or Oracle version etc. >>> >>> Well, what do you get when you print out the query? nrb or id probably >>> don't have the value you think. >>> >>> >>> ------------------------------------------------------------------------------ >>> The demand for IT networking professionals continues to grow, and the >>> demand for specialized networking skills is growing even more rapidly. >>> Take a complimentary Learning@Cisco Self-Assessment and learn >>> about Cisco certifications, training, and career opportunities. >>> http://p.sf.net/sfu/cisco-dev2dev >>> _______________________________________________ >>> cx-oracle-users mailing list >>> cx-...@li... >>> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >>> >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> The demand for IT networking professionals continues to grow, and the >>> demand for specialized networking skills is growing even more rapidly. >>> Take a complimentary Learning@Cisco Self-Assessment and learn >>> about Cisco certifications, training, and career opportunities. >>> http://p.sf.net/sfu/cisco-dev2dev >>> _______________________________________________ >>> cx-oracle-users mailing list >>> cx-...@li... >>> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >>> >> > > > ------------------------------------------------------------------------------ > The demand for IT networking professionals continues to grow, and the > demand for specialized networking skills is growing even more rapidly. > Take a complimentary Learning@Cisco Self-Assessment and learn > about Cisco certifications, training, and career opportunities. > http://p.sf.net/sfu/cisco-dev2dev > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |