How do you iterate over a result set of data?
curs.execute("select * from people")
for row in curs:
print row
for row in curs.fetchall():
print row
curs.execute("select first_name from people")
names = [row[0] for row in curs.fetchall()]
curs.execute("select max(x) from t")
maxValue = curs.fetchone()[0]
row = curs.fetchone()
while row:
print row
row = curs.fetchone()
Tags: python sql database oracle cx-oracle
Source: By Mark Harrison as answer to the question
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 3.0
Related code-snippets:
- Binary data in MySQL.
- What is a change to SQL Server tables?
- Flat file databases are generally stored in a computer hard drive. Flat file databases cannot be shared by any party with another.
- Decoding T-SQL CAST in C#/VB.NET.
- How do I upgrade my SQL Server database version?
- How can I find the full path of a font from its display name on a Mac?
- How do I see preview JPEG file of PDF on Windows?
- How do you swap unique indexed column values in database?
- Redefining an attribute in Python with an index in array of objects using 'in'. If no object is found in an array of objects then it is not correct.
- If a.net Embedded Database runs on a network. Embedded Database can run off a network.
- MySQL and Python are both well written programmers.
- How can I use itertools.groupby()?
- The ability to edit a database by multiple users is essential.
- What is the best way to use a database in c#?
- How can we add a method to an existing Object Instance?