Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
You need to import the SQL type constants from DBI and specify that SQL_LONGVARCHAR as the type of the data to be added to the memo field.

The code below extracts the news from the Google RSS feed and inserts the stories into an Access database via DBI and ODBC. The database connection is made on the fly without needing configuration. The description item is a memo field in the Access database.

#! /usr/bin/perl # use strict; use warnings; use LWP; use XML::RSSLite; use DBI ':sql_types'; use Date::Parse; use Date::Format; use HTML::Entities; use Data::Dumper; my $rssUrl = ' +t=rss'; unless (getRss()) { $ENV{HTTP_PROXY}='myproxy:80'; getRss(); } sub getRss { my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $ua->agent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.11) + Gecko/20050728'); my $response = $ua->get($rssUrl); my $rssContent; if ($response->is_success) { $rssContent = $response->content; # or whatever } my $mdb = "C:\\perl\\rssnewsdb\\rss.mdb"; my $DSN = "driver=Microsoft Access Driver (*.mdb);dbq=$mdb"; my $dbh = DBI->connect("dbi:ODBC:$DSN", ",") or die "$DBI::errstr\n"; if ($rssContent) { $rssContent =~ s/ isPermaLink="false"//g; my %rssHash; parseRSS(\%rssHash, \$rssContent); foreach my $item (@{$rssHash{item}}) { my $sql = "INSERT INTO tFeed ( [guid], title, link, category , + publicationdate, description) VALUES(?,?,?,?,?,?)"; my $sth = $dbh->prepare($sql); my $guid = $item->{'guid'}; my $title = $item->{'title'}; my $link = $item->{'link'}; my $description = $item->{'description'}; my $category = $item->{'category'}; my $publicationdate = time2str ('%c', str2time($item->{'pubDat +e'})); $description =~ s/<.*?>/ /g; $description =~ s/&/&/g; decode_entities $description; $description =~ s/\s+/ /g; $description =~ s/^\s+//g; print "$description\n\n"; $sth->bind_param(1, $guid); $sth->bind_param(2, $title); $sth->bind_param(3, $link); $sth->bind_param(4, $category); $sth->bind_param(5, $publicationdate); $sth->bind_param(6, $description, SQL_LONGVARCHAR); eval { $sth->execute() or die $dbh->errstr; }; if ($@) { print "Failed to add - $title\n"; } } return 1; } else { print "error!\n"; } return undef; }

In reply to Re: Accessing MS-Access memofield via DBI by inman
in thread Accessing MS-Access memofield via DBI by reneeb

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Corion]: ... that's not that great for quasi-disposable devices ;)
    [Eily]: can't you just remote connect to the linux machine ?
    [marto]: IIRC the hiemdal suite made life much easier on windows, and people on XDA developers put out released of windows only pages for adb that made it less of a pain
    [marto]: Eily you can't remote connect the physical device via USB ;)
    [Corion]: Eily: Sure, that's what I do, but some things you need to do on the Android device directly, like when navigating the bootloader :-)
    [Eily]: marto you just need a longer cable :P
    [Corion]: marto: Yeah, but I'm somewhat wary of installing random USB drivers downloaded from , Google Drive or whatever, so Linux wins there due to there being no conflicts and me just having to edit one text file in the worst case, to add the USB vendor
    [hippo]: Long USB cable FTW.
    [Corion]: Eily: I've thought of that, but I don't like running long cables through the appartment because sooner or later I'll trip over it, pulling at least one device off its stand :)
    [marto]: hmm, may have to patch CPAN::Meta to move from search.cpan to metacpan in the META.json/yml files

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (10)
    As of 2018-05-23 09:16 GMT
    Find Nodes?
      Voting Booth?