Re: [cx-oracle-users] iterating using fetchmany
Brought to you by:
atuining
|
From: Anthony T. <ant...@gm...> - 2014-11-26 03:49:38
|
You can also use this code:
for row in cursor_metadata:
print row
Internally this does the equivalent of fetchmany() anyway. You can
determine how big of a buffer you want to use by using cursor.arraysize.
Anthony
On Tue, Nov 25, 2014 at 2:50 PM, Fawcett, David (MNIT) <
Dav...@st...> wrote:
> I don’t see an obvious issue with your code, but you may just want to
> try using .fetchall() Depending on your machine, 20,000 rows shouldn’t be
> a problem.
>
>
>
> Once you have all of the data, you can then iterate through it and do what
> you want with it.
>
>
>
> data = cursor_metadata.fetchall()
>
>
>
> for row in data:
>
> print row
>
>
>
> *From:* Rodman, Daniel [mailto:dr...@bu...]
> *Sent:* Tuesday, November 25, 2014 3:23 PM
> *To:* cx-...@li...
> *Subject:* [cx-oracle-users] iterating using fetchmany
>
>
>
> I'm working with python and oracle using the cx_Oracle module. I'm having
> issues getting fetchmany to iterate over my result set correctly. The table
> in the query, i2test, has over 20,000 rows, however the while loop hangs
> when it gets to about 1,800 rows. If I remove the order by clause... the
> loop hangs at about 12,000. Any advice?
>
>
>
> cursor_metadata = cx_Oracle.Cursor(i_connection)
>
>
>
> query_select = """SELECT name, code, cname, TO_CHAR(updatedate),
> TO_CHAR(downloaddate), TO_CHAR(importdate)
>
> FROM imetadata.i2test
>
> WHERE code like '%DIN%' AND
>
> cd = 'N'
>
> ORDER BY code"""
>
>
>
> cursor_metadata.execute(query_select)
>
>
>
> count = 0
>
> results = cursor_metadata.fetchmany(100)
>
> while results:
>
> print count
>
> count += 1
>
> results = cursor_metadata.fetchmany(100)
>
>
>
> I realize this is probably something simple... thanks in advance.
>
>
>
>
>
> Dan
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> cx-oracle-users mailing list
> cx-...@li...
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
>
>
|