Some helpful tips
Hello,
I've been puzzling over this package for the last few days, and I think I *finally* understand how to make this work as expected!
That said, this is problematic, because the package is rather confusing to use until you understand how. I think the code needs some major refactoring and renaming of objects and methods to make this more clear.
I know Nick has answered a bunch of questions to people trying to understand PySQLPool, but those didn't help me either. Sometimes you just have to read the source!
Here are some things I find helpful to understand:
1. Calling PySQLPool.
2. You don't have to call PySQLPool.
3. Calling PySQLPool.
4. Calling a method like `.query()` on a PySqlQuery object finally DOES establish a connection. It asks the pool for a free existing connection, if one is available. Otherwise it establishes a new connection, up to `maxActiveConne
Once it gets the connection, it executes the query you specified in the method `.query()` This call blocks until the query has finished and the result is returned from the server. Then the connection is returned back to the Pool, and control returns to your code.
5. The `.query...()` methods handle the creation of a MySQLdb Cursor object for you. If you're used to using MySQLdb, you probably do something like:
c = db.cursor(
c.execute("....")
c.close()
Calling the `.query...()` methods on the PySqlQuery object automatically makes a MySQLdb Cursor to execute your query via MySQLdb, and then closes the cursor before control is returned to your code. This cursor is always created as a DictCursor, and is accessible after calling `<PySqlQueryObj
6. The fact that I had to do this much explaining means this package needs some work! What is the development status of the project? I see a lot of '2008's in the code, so I'm guessing ... not much.
I might fork off this project (under a different name, since the API's would have to be incompatible), if anyone else is interested, just let me know.
Eric
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- PySQLPool Edit question
- Assignee:
- Nikoleta Verbeck Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Eric Heller for more information if necessary.