Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 16th, 2003, 08:00 PM
lazy_yogi lazy_yogi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 325 lazy_yogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 58 m 36 sec
Reputation Power: 11
MySQL Problem - connection dies after too many queries

Hi, I'm writing an application and I'm testing it with large data for speed, but I can't even load it!

MySQL dies after about 2000 queries.
I'm going to need a few 100,000's to load it up.
Anyone had this problem before ??

Eli

p.s. Does it have to do with me not closing something after each query ? Here's my db.py file that I use for each query :


Code:
#!/usr/bin/python

import MySQLdb

### return a mysql cursor handle
def connect():

    ### set database parameters
    host = "localhost"
    user = ""
    pwd  = ""
    db   = "video_store"

    ### connect
    db = MySQLdb.connect(host, user, pwd, db)

    ### return the db object
    return db


### this can be called on its own with a query as argument
### it returns the result
def executeQuery(query):

    ### create a db object
    ### if not in this file, use: "mydb = db.connect()"
    mydb = connect()        

    ### get the db handle
    handle = mydb.cursor()

    ### execute the query
    handle.execute(query)

    ### get the results
    result = handle.fetchall()

    ### close the db connection
    mydb.close()

    ### return the results
    return result

Reply With Quote
  #2  
Old November 16th, 2003, 10:33 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,573 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 11 h 9 m 33 sec
Reputation Power: 406
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Im not that much advanced in python, but as from what i know try adding a while loop in your code.. for example

Code:
result = handle.fetchall()
while data in result:
 return data

mydb.close()


let me know if it works

Reply With Quote
  #3  
Old November 17th, 2003, 02:09 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
that is kinda strange, you could try closing your handle/cursor although i dont know if that will do anything. If its MySQL which times out and not Python you might want to ask the MySQL boys why it would be doing this.. we can safly rule out that Pythons running out of memory though.

Code:
    ...
    handle.close()
    ...


Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > MySQL Problem - connection dies after too many queries

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap