Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 559099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:12:08+00:00 2026-05-13T12:12:08+00:00

In cx_Oracle (or Oracle in general), is it possible to allocate a cursor for

  • 0

In cx_Oracle (or Oracle in general), is it possible to allocate a cursor for each query, or to reuse a cursor across several queries.

def getSomeData(curs):         # case 1: pass in a cursor, which is generally
    curs.execute('select ...') #         reused across queries
    return curs.fetchall()

def getSomeData(conn):         # case 2: pass in a connection,allocate
    curs=conn.cursor()         #         a cursor for this query
    curs.execute('select ...')
    return curs.fetchall()

Of course, both approaches return the same data.

What are the tradeoffs between the two approaches? Is one particularly more or less efficient? Are there any potential pitfalls to reusing a cursor over many queries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:12:08+00:00Added an answer on May 13, 2026 at 12:12 pm

    You can re-use a cx_Oracle cursor as much as you like, no problem. If you’re executing thousands of small queries in a small space of time, you might see a slight performance improvement by re-using the cursor, but I doubt it.

    I will sometimes create new cursors, and other times re-use an existing one, depending on whether it makes the code easier to read and understand.

    For example, if I have a variety of procedures that need to access the database, I might pass an Oracle connection object around, or a cursor created on that connection.

    Whatever makes your code more readable and easier to maintain is what I’d go for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use cx_Oracle to connect to an Oracle instance and execute some
Here's my code: import cx_Oracle conn = cx_Oracle.connect(usr, pwd, url) cursor = conn.cursor() cursor.execute(UPDATE
I am having issiues installing cx_oracle. I have installed oracle instantclient and cx_oracle oracle
I'm coding a webservice on python that uses an Oracle database. I have cx_Oracle
I'm using Oracle Database 10g xe universal Rel.10.2.0.1.0 against cx_Oracle-5.0.4-10g-unicode-py26-1.x86_64 on a django project
It seems cx_Oracle doesn't. Any other suggestion for handling xml with Oracle and Python
Okay, so I'm connected to an oracle database in python 2.7 and cx_Oracle 5.1
I have some small python apps that use cx_Oracle to connect to an Oracle
I've installed cx_Oracle (repeatedly) and I just can't get it to work on my
I'm using cx_Oracle to select rows from one database and then insert those rows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.