Professional Web Applications Themes

how to keep database connection persistent - PERL Miscellaneous

Hi, i have a non-cgi script being called by users in command line. this script query database and return data. as this script is called frequently, i would like to keep a database connection so it won't initiate a new db connection. how do i do that ? Regards, Qiang...

  1. #1

    Default how to keep database connection persistent

    Hi,

    i have a non-cgi script being called by users in command line. this script
    query database and return data.
    as this script is called frequently, i would like to keep a database
    connection so it won't initiate a new db connection.

    how do i do that ?

    Regards,

    Qiang


    James Guest

  2. #2

    Default Re: how to keep database connection persistent

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    "James Q.L" <com> wrote in
    news:szekb.8193$bellglobal.com:
     

    You can't. Why do you feel you need to?

    - --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    -----BEGIN PGP SIGNATURE-----
    Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

    iQA/AwUBP5GzmGPeouIeTNHoEQIQ+gCgl2qeIUNMilsnA2sc5IDus4 4y8JoAoN5B
    og/6fo/iDhiruGfENtf50Y5Y
    =MZfN
    -----END PGP SIGNATURE-----
    Eric Guest

  3. #3

    Default Re: how to keep database connection persistent


    "Eric J. Roode" <net> wrote in message
    news:196.97.136... 
    >
    > You can't. Why do you feel you need to?
    >[/ref]

    well. this script is really being called during user printing through our
    print server. it checks user quota in database and proceed if it's
    sufficient.
    so if the query takes longer the user will have to wait longer.

    asides from that, it's good to know if this is doable.

    i found sql relay does that. will give it a go later.
    http://sqlrelay.sourceforge.net/


    Qiang


    James Guest

  4. #4

    Default Re: how to keep database connection persistent

    James Q.L wrote: [/ref][/ref]

    [...]
     

    Not enough time to read through that page, but I'm really surprised -
    isn't it the nature of a command line script that it stops execution
    after it's finished? So obviously it can't keep a connection around in
    memory... Of course you could have a sort of 'Connection Server' that
    keeps pooled connections to the database, and the script connects to
    that server instead of the database. But why should that be more
    efficient than connecting to the database directly?

    Bjoern

    --


    Let's not weep for their evil deeds,
    but for their lack of imagination
    (Nick Cave)

    Bjoern Guest

  5. #5

    Default Re: how to keep database connection persistent

    On Sat, 18 Oct 2003 13:15:40 -0400
    "James Q.L" <com> wrote:
     

    Depends on what you're doing and what kind of effort you want to put
    into writing the script. You could, for eaxample, use 'fork'
    (untested) to execute an 'update' SQL statement, but the initial
    connection and final closing of the connection would be performed
    outside of the fork by the parent process. I'm thinking that, because
    you already created a DBI object in the parent, the children would
    re-use the connection. One of the issues you'd encounter is locking
    of the records (multiple writes/updates being performed).

    It's, IMHO, less of a headache to just re-connect to the database each
    time you need to do something. Unless you have _really_ slow
    connections :-)

    HTH

    --
    Jim

    Copyright notice: all code written by the author in this post is
    released under the GPL. http://www.gnu.org/licenses/gpl.txt
    for more information.

    a fortune quote ...
    U: There's a U -- a Unicorn! Run right up and rub its horn.
    Look at all those points you're losing! UMBER HULKS are so
    confusing. -- The Roguelet's ABC
    James Guest

Similar Threads

  1. Persistent Connection Question
    By Dumbass in forum PHP Development
    Replies: 7
    Last Post: April 18th, 10:33 AM
  2. When to use a persistent mysql db connection ?
    By Pugi! in forum PHP Development
    Replies: 2
    Last Post: January 28th, 10:03 PM
  3. persistent socket connection
    By sean in forum Macromedia Director Lingo
    Replies: 4
    Last Post: December 31st, 11:19 PM
  4. Maintains a persistent connection
    By Ascll in forum PHP Development
    Replies: 2
    Last Post: September 25th, 04:41 AM
  5. [PHP] Maintains a persistent connection
    By Chris Shiflett in forum PHP Development
    Replies: 0
    Last Post: September 25th, 02:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139