http://qs321.pair.com?node_id=314564

lwicks has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to install/use DBD::CSV on a server that does not have it installed already. I only have FTP access however to the server in question. If not, recomendation on how to implement flatfile database functions would be appreciated.

Replies are listed 'Best First'.
Re: DBD::CSV - how to install? (FTP only)
by tcf22 (Priest) on Dec 13, 2003 at 22:33 UTC
    If you only have FTP access, I assume you can't write to the perl library directories, so you could upload other libraries to $ENV{HOME}/perl/libs and put
    use lib "$ENV{HOME}/perl/libs";
    at the top of your programs.

    Note: Any libraries with XS code may have problems, since they have to be compiled locally, then uploaded. This should work for all perl-only modules.

    Update: Changed ' to " because variable is used.

    - Tom

      Exactly right. I only have FTP access to my user directory on a webserver. I am writing a web app and rather than commit the sin of writing my own database handling routines, I wanted to use DBI and specifically DBD::CSV as I wanted to use text files on the same server. BUt neither of the servers I have tested on have DBD::CSV installed (Both have DBI) So I am wondering if I can like you suggest copy DBD::CSV into my user directory and then have DBD::CSV available for this application. Anyone actually done this before?
      Exactly right. I only have FTP access to my user directory on a webserver.

      I am writing a web app and rather than commit the sin of writing my own database handling routines, I wanted to use DBI and specifically DBD::CSV as I wanted to use text files on the same server. BUt neither of the servers I have tested on have DBD::CSV installed (Both have DBI)

      So I am wondering if I can like you suggest copy DBD::CSV into my user directory and then have DBD::CSV available for this application.

      Anyone actually done this before?

Re: DBD::CSV - how to install? (FTP only)
by jZed (Prior) on Dec 14, 2003 at 02:12 UTC
    The posters above are correct, DBD::CSV requires Text::CSV_XS which needs to be compiled. If you can compile it on a machine of the same platform, you can then upload that.

    Or, you can install DBD::AnyData instead. It does not require any XS modules and has a CSV mode that behaves identically to DBD::CSV (except for 1. speed and 2. ability to handle embedded newlines). You will need to install its prerequisites - AnyData (in addition to DBD::AnyData), DBD::File and SQL::Statement, all of which are also pure perl so can just be FTP'd onto the server.

      Many thanks for the replies, I shall have a shot with AnyData.

      Sadly never used it, so is anyone here able to help me through the process of installing via FTP and getting it working.?

      ---

      Kia Kaha, Kia Toa, Kia Manawanui!
      Be Strong, Be Brave, Be perservering!

        For the installation:

        1. download the module from CPAN

        2. have a look at the included Makefile.PL for module dependencies (they are in the hashReference with the key PREREQ_PM in the form Modulename => version, and have a look if these prerequisites are installed. If no, start over with that module and so on. If yes, continue with the next step

        3. upload the module via FTP and unpack it to a temporary directory

        4. If you've got acces to a make, you can install the module to your own directory by calling

        perl Makefile.PL PREFIX=/path/to/your/private/modulelib make make test make install

        5. If you have to install more modules, set the environmentvariable PERL5LIB to your /path/to/your/private/modulelib, e.g. in bash: export PERL5LIB=/path/to/your/private/modulelib and start over with step 3.

        6. use your module-lib from your perl-scripts with use lib qw(/path/to/your/private/modulelib/) or the like (sometimes the StandardModule Findbin might also be interesting for you)

        If you don't have access to make, you could try to copy the files to your directories, but that will only work if they are pure perl-modules. If not, you could try to set up a system as similar as your webserver and compile it there, but it is very difficult to get a nearly identical environment; there you better look around for other (already installed) modules that can do the job of persistance, too (e.g. DB_File, Tie::File, ...) or rely on Data::Dumper for persistance. You could also rely to Storable with is a very fast and compact solution, but if this module is updated, it sometimes can't read the data from it's older version

        BTW: if you don't have shell access like telnet or ssh, you could also fire these commands by a cgi-script (or write it to a bash-script and execute it from your cgi. But better care for errors and failure or you will get troubles when using these modules

        Best regards,
        perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

        I've packed everything you'll need for DBD::AnyData (except DBI) into AnyData-Standalone It will allow you to install all of the pre-required modules (all maintained by me, BTW) with only FTP access. Here's the README for AnyData-Standalone:
        AnyData::Standalone -- install AnyData without make or compile
        
        WHAT IT IS (AND ISN'T)
        
         This package includes all of the files needed to install AnyData
         and DBD::AnyData.  It is *only* for extreme cases where you can't
         use CPAN or PPM or manual install (for example if you only have
         FTP access to a server or you are installing onto a PDA or other
         limited environment).  If you are using this package to avoid
         learning how to install modules, please don't do that.  Learn to
         install modules, it will really, really help you in the long run.
        
        HOW TO INSTALL
        
         Unpack this package in the desired location (or unpack it locally and
         then FTP the resulting MyLib directory to the final location).  In
         scripts that call the modules put this at the top:
        
             use lib 'path/MyLib';   # path = wherever you unpacked MyLib
        
         This package does not include DBI.  If you want to use DBD::AnyData,
         you'll need to install DBI separately.  DBI also has a Pure Perl
         version that can be installed without compile or make, see the DBI
         and DBI::PurePerl docs for further info.
        
        WHAT VERSIONS ARE INCLUDED
        
             AnyData        0.08
             DBD::AnyData   0.06
             DBD::File      0.22
             SQL::Statement 1.005
        
        =head1 DOCUMENTATION
         
         The documentation for each module is included with the module, use
         perldoc <module_name> or just read the pod section in a text viewer
         or look up the docs online at http://search.cpan.org/~jzucker/.
        
Re: DBD::CSV - how to install? (FTP only)
by Necos (Friar) on Dec 14, 2003 at 00:46 UTC
    Hmmm... I just installed DBD::CSV via CPAN.pm, and I noticed that it requires Text::CSV_XS and SQL::Statement. The Text::CSV_XS is an XS module that needs to be compiled, and I'm pretty sure you can't do that with FTP access. Maybe you can cross compile it on your machine without any optimizations and then upload it. Hmmm... On second thought, that probably won't work since the perl source headers are used to compile XS modules.

    Isn't there a module Text::CSV or something like that? If not, you'll have to roll your own CSV parser.

    Theodore Charles III
    Network Administrator
    Los Angeles Senior High
    email->secon_kun@hotmail.com
    perl -e "map{print++$_}split//,Mdbnr;"
Re: DBD::CSV - how to install? (FTP only)
by TomDLux (Vicar) on Dec 13, 2003 at 22:32 UTC

    Yes, you can use FTP to copy the files to your home directory.

    If you only have ftp access, how will you invoke your scripts?

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

      I have FTP access to upload files and standard web access to view the output.
Re: DBD::CSV - how to install? (FTP only)
by Eyck (Priest) on Dec 16, 2003 at 08:58 UTC

    You can always add module directly to your programs - it's enough to past it to your program and then you can use it.

    You can always do something like this: ftp modules to the destination. in your script:

    use lib '/path/to/ftp/directory' use DBD::CSV

    Besides DBD::CSV there are cute modules like DBD::SQLite...