Open bokov opened 10 years ago
Test of comment
?Hello Alex,
How are you doing Alex? I hope you all doing well on everything especially your the other degree things. Finger crossed.
I'm back to Texas. I took a look of code of simSQL2.py ... I cant solve the issue of line 137 would you please help me to take a look when you have time?
Thank you I really appreciate that.
Bob
From: bokov notifications@github.com Sent: Sunday, June 15, 2014 9:19 PM To: UTHSCSA-CIRD/simSQL Cc: Chien, Jung-Ting Subject: Re: [simSQL] Use zip(), subsetting, indexing, and string manipulation to finish the simTable() command (#3)
Test of comment
Reply to this email directly or view it on GitHubhttps://github.com/UTHSCSA-CIRD/simSQL/issues/3#issuecomment-46128277.
There is a more standard and beautiful solution than iterating over an object inside square brackets like we discussed last week.
Some of the sub-items contain spoilers, so read and attempt each one before reading the next.
zip()
function in the Python shell until you understand what it does.tabletemp
.tabletemp
a column of data or a row of data? How can you tell?zip()
function? Try incorporating it after line 121 of simSQL2.pytabletemp
?tabletemp
? Review the Python documentation for dictionaries if you need to.zip()
expects multiple lists as arguments. In Python, there is a way to unpack an iterable object into multiple function arguments. Read about it here: https://agiliq.com/blog/2012/06/understanding-args-and-kwargs/ . This will tell you more than you need to know for this ticket, but you will need this information for a future ticket, so it's all going to be useful.tabletemp
into a collection of rows.insert into FOOTABLE(COLA,COLB,COLC,...) values(?,?,?,...)
where theCOLX
etc. should be replaced by column names for that table andFOOTABLE
by thetableName
variable. The,...
indicates that the number of variables can vary (there will be as many variables as there are columns, which is the same as saying that there will be as many variables as the length of each row you created above). The?
s should remain question-marks, but there should be as many of them as there are variables. ModifysimTable()
to print that string instead of printingtabletemp
."insert into "
) to a string that is stored in a variable (e.g.tableTemp
)?tabletemp
dictionary. What method of the dictionary object do you use to get those keys as a list? Can this list be concatenated directly to a string literal?.join()
method. Google it to understand how to use it. Do you see where it will be needed for constructing your insert string?*
, that allows you to replicate strings. For example'Z3'*5
returns'Z3Z3Z3Z3Z3'
. Do you see where it will be needed for constructing your insert string??
are). You can usecur.execute(FOO,BAR)
whereFOO
is your insert string (or a variable you assigned it to) andBAR
is a list object of the same length as the number of?
placeholders. Try actually running this in the Python debugger (the second breakpoint, within the body ofsimTable()
.simTable()
so that it iterates over all the rows you created usingzip()
and uses each one as the second argument forcur.execute()
as above.