Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Open and Close a database connection in a request
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ProfessionalIT  
View profile  
 More options Sep 19 2012, 3:54 pm
From: ProfessionalIT <lsever...@gmail.com>
Date: Wed, 19 Sep 2012 12:54:12 -0700 (PDT)
Local: Wed, Sep 19 2012 3:54 pm
Subject: Open and Close a database connection in a request

How to implement this ?

When I init the request I need open a connection with the database (and
execute a query for example) and in the end of the request I need close the
database connection.

Another question is: How I know that a database connection is open ?

ps: sorry by my 'dummie questions' and by my terrible english !.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ProfessionalIT  
View profile  
 More options Sep 19 2012, 4:54 pm
From: ProfessionalIT <lsever...@gmail.com>
Date: Wed, 19 Sep 2012 13:54:30 -0700 (PDT)
Local: Wed, Sep 19 2012 4:54 pm
Subject: Re: Open and Close a database connection in a request

Well,

   I'm trying implement this then in my code.py I have this code:

from model import setDB, unsetDB

def db_handler(handler):
    setDB()
    result=handler()
    unsetDB()
    return result

webapp = web.application(urls, globals())
webapp.add_processor(db_handler)

im my model.py I have this code:

db = web.database(dbn=DBN, host=HOST, db=DB, user=USER, pw=PWD)

def unsetDB():
    print '>>>>>>>>> in the unset <<<<<<<<<<<'
    db = None
    print str(db)

def setDB():
    print '>>>>>>>>> in th SET <<<<<<<<<<<'
    unsetDB()
    db = web.database(dbn=DBN, host=HOST, db=DB, user=USER, pw=PWD)
    print str(db)

but when I look in my system process monitor I still have a opened
connection with database

any idea ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Francois Dion  
View profile  
 More options Sep 19 2012, 8:46 pm
From: Francois Dion <francois.d...@gmail.com>
Date: Wed, 19 Sep 2012 17:46:28 -0700 (PDT)
Local: Wed, Sep 19 2012 8:46 pm
Subject: Re: Open and Close a database connection in a request

On Wednesday, September 19, 2012 3:54:12 PM UTC-4, ProfessionalIT wrote:

> How to implement this ?

> When I init the request I need open a connection with the database (and
> execute a query for example) and in the end of the request I need close the
> database connection.

Por que fechar a conexão?

Normally, for performance, you want to open the connection as soon as you
get a chance and _keep_ it open. What problem are you trying to solve?

Tchau,
Francois

--
Francois Dion
http://solarisdesktop.blogspot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ProfessionalIT  
View profile  
 More options Sep 19 2012, 9:51 pm
From: ProfessionalIT <lsever...@gmail.com>
Date: Wed, 19 Sep 2012 18:51:20 -0700 (PDT)
Local: Wed, Sep 19 2012 9:51 pm
Subject: Re: Open and Close a database connection in a request

> Por que fechar a conexão?

> Normally, for performance, you want to open the connection as soon as you
> get a chance and _keep_ it open. What problem are you trying to solve?

> Tchau,
> Francois

> Francois,

    Well, I think that when many visitants access the website (where each
access is a new browser session and a new database connection correct ? )
 this can leave the website slow.

     Actually I still don't know how...I don't understand how the
connections works in web.py, for example, I don't know when the connection
is closed.

    But, thank you so much for your replay.

    Best regards,
    Leandro.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ProfessionalIT  
View profile  
 More options Sep 21 2012, 9:04 am
From: ProfessionalIT <lsever...@gmail.com>
Date: Fri, 21 Sep 2012 06:04:57 -0700 (PDT)
Local: Fri, Sep 21 2012 9:04 am
Subject: Re: Open and Close a database connection in a request

 Friends,

   Any idea ?, tip ? or suggestion ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Francois Dion  
View profile  
 More options Sep 21 2012, 10:17 am
From: Francois Dion <francois.d...@gmail.com>
Date: Fri, 21 Sep 2012 10:11:04 -0400
Local: Fri, Sep 21 2012 10:11 am
Subject: Re: [webpy] Re: Open and Close a database connection in a request
Bom dia,

I dont see what the problem is. What database are you using? What kind
of load are you talking about?

Francois

--
Francois Dion
http://solarisdesktop.blogspot.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tomas Schertel  
View profile  
 More options Sep 21 2012, 1:35 pm
From: Tomas Schertel <tscher...@gmail.com>
Date: Fri, 21 Sep 2012 10:35:18 -0700 (PDT)
Local: Fri, Sep 21 2012 1:35 pm
Subject: Re: [webpy] Re: Open and Close a database connection in a request

Hi Leandro,

Have you monitored your database to see how many connections does it has?
I may be wrong, but I think db connections number aren't related to
sessions number.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »