<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    One way, if there isn't too much info, is to store the user data in
    their session, probably safest to use a server-based session for
    this (JSON, YAML, Storable, DBIC, etc). If there is a *lot* of data
    this might not be practical, but still the query could be selective
    using the session username. This is what I do for one of my apps and
    it works fine.<br>
    <br>
    <div class="moz-cite-prefix">On 21/09/2015 10:51, Dancer New wrote:<br>
    </div>
    <blockquote
cite="mid:CAD=mRB0uP_BmV-OEeysMFYAvoE7gGMrDuDTwkNYkdh66PPPZUQ@mail.gmail.com"
      type="cite">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Fri, Sep 18, 2015 at 5:39 PM,
            Maxwell Carey <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:mcarey@ucar.edu" target="_blank">mcarey@ucar.edu</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr"><br>
                <div class="gmail_extra"><br>
                  <div class="gmail_quote"><span class="">On Fri, Sep
                      18, 2015 at 10:32 AM, WK <span dir="ltr"><<a
                          moz-do-not-send="true"
                          href="mailto:wanradt@gmail.com"
                          target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:wanradt@gmail.com">wanradt@gmail.com</a></a>></span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0px
                        0px 0px 0.8ex;border-left:1px solid
                        rgb(204,204,204);padding-left:1ex">Hi!<br>
                        <span><br>
                          2015-09-18 19:09 GMT+03:00 Dancer New <<a
                            moz-do-not-send="true"
                            href="mailto:dancerfan2015@gmail.com"
                            target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:dancerfan2015@gmail.com">dancerfan2015@gmail.com</a></a>>:<br>
                          <br>
                          > I use Dancer::Plugin::Database in my
                          application. Each time when<br>
                          > $dbh = DBI->connect( $c->{ dsn },
                          $c->{ username }, $c->{ password},
                          $c->{<br>
                          > dbi_params })<br>
                          > is called. does it return a new
                          connection?<br>
                          <br>
                        </span>Yes, it does. But then is no point to use
                        Dancer::Plugin::Database at all.<br>
                      </blockquote>
                    </span>
                    <div><br>
                      <div>
                        <div>To expand on this a little, with
                          Dancer::Plugin::Database, you should be using
                          the 'database' function instead of calling
                          DBI->connect. See the documentation here <a
                            moz-do-not-send="true"
href="https://metacpan.org/pod/Dancer::Plugin::Database#GETTING-A-DATABASE-HANDLE"
                            target="_blank"><a class="moz-txt-link-freetext" href="https://metacpan.org/pod/Dancer::Plugin::Database#GETTING-A-DATABASE-HANDLE">https://metacpan.org/pod/Dancer::Plugin::Database#GETTING-A-DATABASE-HANDLE</a></a><br>
                          <br>
                          "Calling <code>database</code> will return a
                          connected database handle; the first time it
                          is called, the plugin will establish a
                          connection to the database, and return a
                          reference to the DBI object. On subsequent
                          calls, the same DBI connection object will be
                          returned, unless it has been found to be no
                          longer usable (the connection has gone away),
                          in which case a fresh connection will be
                          obtained."<br>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>Thanks for the explanation.</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">
                <div class="gmail_extra">
                  <div class="gmail_quote">
                    <div>
                      <div>
                        <div><br>
                        </div>
                      </div>
                       </div>
                    <span class="">
                      <blockquote class="gmail_quote" style="margin:0px
                        0px 0px 0.8ex;border-left:1px solid
                        rgb(204,204,204);padding-left:1ex">
                        <span><br>
                          > I would like one db connection for each
                          user, where can I save the database<br>
                          > handler?<br>
                          <br>
                        </span>Could you elaborate, why every user must
                        have their own connection? It<br>
                        does not seem reasonable. Using just one
                        connection over the<br>
                        application is much cheaper way. When using
                        Dancer::Plugin::Database<br>
                        you must set up connection data in config file.<br>
                        <br>
                      </blockquote>
                    </span>
                    <div><br>
                      You can define multiple connections so that
                      database('foo') will connect with one set of
                      connection parameters and database('bar') will use
                      another. See <a moz-do-not-send="true"
href="https://metacpan.org/pod/Dancer::Plugin::Database#DEFINING-MULTIPLE-CONNECTIONS"
                        target="_blank">https://metacpan.org/pod/Dancer::Plugin::Database#DEFINING-MULTIPLE-CONNECTIONS</a><br>
                      <br>
                      But I agree, this seems like a bad idea. What
                      exactly are you trying to do?<br>
                    </div>
                  </div>
                </div>
              </div>
              <br>
            </blockquote>
            <div><br>
            </div>
            <div>I want to make sure each user only see their own data.</div>
            <div>So in the database, I have a procedure to set the
              context. By calling this procedure, it records that this
              database session is for the particular user, any
              subsequent queries is for the particular user.</div>
            <div><br>
            </div>
            <div>If I use the same database connection for all of the
              queries, when a user comes in and the database set context
              for the user, but at the same time another user comes in,
               then will the database think it is the previous user, and
              return the data of the previous user to the new user?</div>
            <div><br>
            </div>
            <div>If I don't use one database connection for each user,
              how can I make sure the database handler know which user
              it is dealing with?</div>
            <div><br>
            </div>
            <div>Many thanks,</div>
            <div>Dan</div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br>
              dancer-users mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
              <a moz-do-not-send="true"
                href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users"
                rel="noreferrer" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
dancer-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a>
<a class="moz-txt-link-freetext" href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Richard Jones</pre>
  </body>
</html>