Interesting.. I'll have to dig out my unit test scripts that I wrote to
test the situation to my satisfaction...
The way I had it , I wrote the query exactly as was done in this case,
but I wrote it directly in the cursor.execute() function as in:
cursor.execute('''insert into tablea (id,name,nu
Brian Gustin wrote:
> python in this form uses BIND variables..
> >>query = '''UPDATE cost_grid
> >> SET cost_1 = %s <--- %s = the bind variable
> placeholder/formatter
> >> WHERE cost_grid_id = %s
> >> AND finish_dro = %s % ( a,c,b) <--- the raw
python in this form uses BIND variables..
>>query = '''UPDATE cost_grid
>> SET cost_1 = %s <--- %s = the bind variable
placeholder/formatter
>> WHERE cost_grid_id = %s
>> AND finish_dro = %s % ( a,c,b) <--- the raw tuple
That is, what is provi
I wonder if it could not be the extra comma (,) at the end of your sql ?
thus: ..?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,)<--- see trailing
comma, and no matching ? could be a value count != column count
mis-match make sure you have the correct number of values to each
column :)
On the oth
Terry Carroll wrote:
> On Wed, 12 Apr 2006, Victor Bouffier wrote:
>
>> In [285]: n = 0x2018
>>
>> In [286]: n
>> Out[286]: 8216
>
> Victor --
>
> I've seen this notation 00 e.g., In [286], Out[286] -- in a few people's
> postings. What variety of Python does this?
IPython
http://ipython.scip
Alan Gauld wrote:
> Hi John,
>
> I've no idea why its not working but this illustrates why I prefer to create
> the sql string outside the execute - its a lot easier to debug when you can
> print the string exactly as passed to execute. I know many others like to
> leave execute to do the escaping
Hi,
I have taken on board the advice in relation to the cvs module and setting the list to a tuple. I am now using the following code and
getting a different error. I think
it is a small step forward?
import string, re
path =
"c:/test/import.csv"
listy = []
import csv
reader =
Hoffmann wrote:
> So, I wrote the script below:
>
> class Time:
> pass
>
> hour = int( raw_input('Enter the hour: ') )
> min = int( raw_input('Enter the minute: ') )
> sec = int( raw_input('Enter the sec: ') )
>
> time = Time()
> time.hours = hour
> time.minutes = min
> time.seconds
Hoffmann wrote:
> class Time:
> def __init__(self, hours = 0, minutes = 0, seconds =
> 0):
> self.hours = hours
> self.minutes = minutes
> self.seconds = seconds
>
> def printTime(self): # By convention, the first
> parameter of a metho
Bri,
Print stat gives
Insert into cost_grid values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,)
Tracebac
instead of
c.execute(stat, listy[-1])
try
sql_list = listy[-1]
c.execute(stat, sql_list)
Also
what does print stat give you?
maybe one of those two would tell us ..
Bri!
John CORRY wrote:
> Hi,
>
>
>
> I couldn’t sleep last night with all the code running though my head.
> Counting sheep d
Hi,
I couldn’t sleep last night with all the code running
though my head. Counting sheep didn’t
work as I kept wanting to turn them into a loop!
listy[-1]
Outputs the following:-
['432',
'TM BLIND', 'RO', 'PF1', 'Plain Finish Range One', '304.8', '', '45.7', '80',
'90', '0'
> Can I use string formatting in my own functions, or is it stuck with
> builtins?
No, you can use it too.
> It doesn't make much sense for me, but I don't understand the following
> error:
> In [2]: def printd(arg):
> ...: print('>>> %s') % arg
The format operator needs to be with the
>> Personally I prefer to put the initialisation
>> into an __init__() method,
> Thanks for your comments. Please, see below a new
> version of that exercise. What do you think?
> hour = int( raw_input('Enter the hour: ') )
> min = int( raw_input('Enter the minute: ') )
> sec = int( raw_input('
14 matches
Mail list logo