Mojolicious does not use threads, but it does use event-driven callbacks. Maybe that's what you meant? It is true that you can't use regular DBI methods for the queries if you are expecting to respond to event-driven requests. However, I don't think SQLite can be event-driven anyway, because it is a library that runs in your own thread rather than acting like a server which you could asynchronously exchange events with.

That said, Mojo doesn't *need* to be used event-driven. You can run a pre-forked worker pool of Mojo app processes just like any of the other frameworks. In this mode, you just use DBI like normal. But, if you want to make use of Websockets, you do need the event-driven style and an event-driven server like Twiggy.

For Mojo to asynchronously talk to a database and respond to events when the queries complete, while processing other requests in the meantime, you need to use the custom database connectors like Mojo::Pg, and use the promise-returning methods like query_p.


In reply to Re: Database access and async web framework (like Mojolicious) by NERDVANA
in thread Database access and async web framework (like Mojolicious) by bliako

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.