I did not know about state! Thanks. (Previously I said I knew perl 40% now I will get this down to 30)

To the point, how does passing a DBI connection object around separate perl programs should work in the first place? Either by saving it as a string to a (ENV) variable or serialising it and saving it to a file? I do assume you pass said object around different perl executables/programs because you talk about the ENV right?

I have just used Sereal to save a DB connection object to file and read again. It works (i guess fine, tested read-only and from the same executable instance, i.e. create, save, read, execute all in same executable) as far as executing statements. It returns same results as original handle. But when it comes to disconnect() I get a nasty is not a DBI handle (has no magic) (nasty in the sense that it spits out from the guts its SV, RV, IV...

And expectedly I guess because in retrospect I read from DBI:

If you try to create your own handles using bless() then you'll find the DBI will reject them with an "is not a DBI handle (has no magic)" error.

So, is there a best practice to share DB connection objects among separate perl executables or is something not possible and I misunderstood the setting?

And btw that's probably a bug in Sereal not treating DBI connection objects specially?

bw, bliako

Edit/Update: I can also report that the de-serialised db connection object (the one read from file) is cleaned up automatically when out-of-scope.


In reply to Re^2: Custom $ENV after upgrade not holding DBI connection by bliako
in thread Custom $ENV after upgrade not holding DBI connection by ChrisOfVa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.