Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^5: Perl Contempt in My Workplace

by vkon (Curate)
on May 05, 2021 at 16:26 UTC ( #11132075=note: print w/replies, xml ) Need Help??


in reply to Re^4: Perl Contempt in My Workplace
in thread Perl Contempt in My Workplace

this is what I've tried
use strict; use DBI; use DataTables; my $dbfile = 'base.db'; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","",""); my $dt = DataTables->new(dbh => $dbh); #set table to select from $dt->tables(["t"]); #set columns to select in same order as order of columns on page $dt->columns(["LPAR", "UCODE", "BOX", "Serial Number", "Box Name", "TE +ST", "N_OF_TEST", "N_OF_ERR"]); use Mojolicious::Lite; #print json back to browser get '/data-source' => sub { my $c = shift; $dt->print_json; }; app->start;
Ok, now I've remembered on what's missing here.
I need to work with database of 10_000_000+ records, those do not fit just JSON.

I see that this module recently updated... How can I trust version 0.08? Author makes it clear that the module far from robust?

Replies are listed 'Best First'.
Re^6: Perl Contempt in My Workplace
by 1nickt (Abbot) on May 05, 2021 at 17:02 UTC

    DataTables doc makes clear that for a set that large you need to use server-side processing. This involves passing query params to a listening program on the server, for paging, filtering etc. It may be possible to write a plugin for a web framework providing the ajax routes, but there'd be so much config based on the individual application that it's difficult for me to see how to abstract enough to make it useful.


    The way forward always starts with a minimal test.
      I understand that.
      can you point me to perl solution to the problem? I need excel-like sorting and filtering - please show me and I will switch to it immediately
Re^6: Perl Contempt in My Workplace
by marto (Cardinal) on May 05, 2021 at 17:13 UTC

    "I need to work with database of 10_000_000+ records, those do not fit just JSON."

    Again, this has nothing to do with perl. The DataTables (JavaScript library, not Perl module) is very clear that you're doing it wrong, you can't have read the documentation for the tool you've decided to use. Server Side Processing. This would be the case regardless of what language you choose. You could or add clauses to your search query and/or page results, neither of which you've done. I don't use this module at all, and just return JSON data as explained earlier.

    "How can I trust version 0.08? Author makes it clear that the module far from robust?"

    Where does the author make it clear that is it 'far from robust'? How do you trust any other module or code you pull down regardless of language? Again, no perl/cpan issue here.

      given that I am doing it wrong - can you suggest the right way?

      what CPAN module should I use for the "server-side processing"?

      regarding 0.08 - I treat "0.0x" versions as "experimental" - the released version should be at least 1.0+ - am I wrong again with this assumption?

        what CPAN module should I use for the "server-side processing"?

        Why do you need a module? Can you describe what such a module would do?

        So you have a web server and you receive an ajax request with all the many parameters needed to fetch the next page of results. If you were using a module and you wanted to provide those parameters and get back JSON, what would the module do? Isn't it only to query the DB and convert the results to JSON? So what should the module do? Wrap up the DB query with some layers of abstraction? By the time you wrote the config needed you could have written the handler directly with DBI.

        I admit I often have some custom filtering/ordering code in the ajax route handler that preprocesses the DB query but as I said before I don't see how that could productively be abstracted.


        The way forward always starts with a minimal test.

        Yes, in general. There is nothing semantically significant about a module with a version number less than 1.0.


        🦛

        A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132075]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2021-10-19 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (77 votes). Check out past polls.

    Notices?