Ah, I guess it's only %s and strings for execute? At anyrate, the third argument to connection.execute(self, query, parms=None), params, is a list of strings, each member of the list should have a '%s' placeholder in the query. The string-formatting link is a not really germane ..
On Apr 23, 4:32 pm, Skylar Saveland <skylar.savel...@gmail.com> wrote: > Looking at the source for execute on django-trunk in > django.db.backends.oracle > > If you have a param, you will have an arg for the query (type: > string). > > http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-... > > ... your params should be a list of things to interpolate into the > query string, yes? > > http://docs.python.org/library/stdtypes.html#string-formatting > > On Apr 23, 3:59 pm, Tim Sawyer <list.dja...@calidris.co.uk> wrote: > > > > > > > Hello. > > > This code works fine: > > > >>> import cx_Oracle > > >>> lDsn = cx_Oracle.makedsn(lDatabaseHost, int(lDatabasePort), > > lDatabaseName) > > >>> lConnectString = "%s/%...@%s" % (lDatabaseUsername, > > lDatabasePassword, lDsn) > > >>> lConnection = cx_Oracle.connect(lConnectString) > > >>> cursor = lConnection.cursor() > > >>> lOutput = cursor.var(cx_Oracle.STRING) > > >>> cursor.execute("BEGIN :out := 'N'; END;", {'out' : lOutput}) > > >>> print lOutput > > <cx_Oracle.STRING with value 'N'> > > >>> print lOutput.getvalue() > > N > > > However, if I change this to get the connection from Django, it all > > falls in a big heap: > > > >>> from django.db import connection > > >>> cursor = connection.cursor() > > >>> import cx_Oracle > > >>> lOutput = cursor.var(cx_Oracle.STRIN > > >>> cursor.execute("BEGIN :out := 'N'; END;", {'out' : lOutput}) > > Traceback (most recent call last): > > File "<console>", line 1, in <module> > > File "/dev/HEAD/INTERNAL/websites/Wam3\django\db\backends\util.py", > > line 19, in execute > > return self.cursor.execute(sql, params) > > File "/web/djangocourse\django\db\backends\oracle\base.py", line 435, > > in execute > > query = convert_unicode(query % tuple(args), self.charset) > > TypeError: not all arguments converted during string formatting > > > Can anyone point me in the direction of how I can fix this? > > > Cheers, > > > Tim. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.