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 8433153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:18:32+00:00 2026-06-10T06:18:32+00:00

I am using python 2.7, pyodbc and mysql 5.5. I am on windows I

  • 0

I am using python 2.7, pyodbc and mysql 5.5. I am on windows

I have query which returns millions of rows and I would like to process it in chunks.
using the fetchmany function.

He a portion of the code

import pyodbc
connection = pyodbc.connect('Driver={MySQL ODBC 5.1 Driver};Server=127.0.0.1;Port=3306;Database=XXXX;User=root; Password='';Option=3;')

cursor_1 = connection.cursor()
strSQLStatement = 'SELECT x1, x2 from X'

cursor_1.execute(strSQLStatement)
# the error occurs here  

x1 = cursor_1.fetchmany(10)
print x1
connection.close()

My problem:

  1. I get the error MySQL client ran out of memory

  2. I guess that this is because the cursor_1.execute tries to read everything into memory and tried the following (one by one) but to no avail

    1. In user interface (ODBC – admin tools) I ticked the “Don’t cache results of forwarding-only cursors”
    2. connection.query(“SET GLOBAL query_cache_size = 40000”)

My question:

  1. Does pyodbc has the possibility to run the query and serve the results only on demand ?

  2. The MySQL manual suggests to invoke mysql with the –quick option. Can this be done also when not using the command line?

Thanks for your help.

P.S: suggestions for an alternative MySQL module are also welcome, but I use portable python so my choice is limited.

  • 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-06-10T06:18:33+00:00Added an answer on June 10, 2026 at 6:18 am

    Using MySQLdb with SSCursor will solve your issues.

    Unfortunately the documentation isn’t great but it is mentioned in the user guide and you can find an example in this stackoverflow question.

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

Sidebar

Related Questions

Using Python I would like to find the date object for last Wednesday. I
I'm using Python v2.6 and I have a string which contains a number of
I'm using pyodbc to query an AS400 (unfortunately), and some column names have hashes
I am using Python 2.7 on Windows XP. I have a simple python script
Using Python's Imaging Library I want to create a PNG file. I would like
I have a Python script that writes to a MySQL database using mysql-python .
Using Python module re, how to get the equivalent of the \w (which matches
Using Python, how does one parse/access files with Linux-specific features, like ~/.mozilla/firefox/*.default ? I've
Im using python to access a MySQL database and im getting a unknown column
I have a setup using Pyodbc, UnixODBC and FreeTDS, but somewhere in there some

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.