|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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
|
|
#2
|
||||
|
||||
|
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 ![]()
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#3
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > MySQL Problem - connection dies after too many queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|