how to use PySQLPool

Asked by omathew

Can you give me an example to understand how to use PySQLPool

Question information

Language:
English Edit question
Status:
Solved
For:
PySQLPool Edit question
Assignee:
No assignee Edit question
Solved by:
Nikoleta Verbeck
Solved:
Last query:
Last reply:
Revision history for this message
Best Nikoleta Verbeck (nerdynick) said :
#1

Sorry for the delayed response but the basics are as follows.

import PySQLPool

connection = PySQLPool.getNewConnection(host = 'localhost', username='user', password='pass', schema='mysql')
query = PySQLPool.getNewQuery(connection = connection)
query.Query("YOUR SQL")
for row in query.record:
   row['COLUMN NAME']

You can reuse the connection Object all you wish or you can recreated it every time. It is used as a container for all your connection settings. Also once you have a query object created you can call query.Query() all you want and it will allocate the connection resource from the connection pool for you.

You also have access to the properties query.rowcount and query.affectedRows for the last executed query.

I'm also hoping to get a PyDoc/Wiki or something else up with more examples of how to use the whole thing. As well as how everything works.

Revision history for this message
omathew (oommenkm) said :
#2

Thanks a lot Nick! It works!!!
Your code works smoothly. I got the correct output.
Thanking you once again.
OMathew