gbotzz has asked for the wisdom of the Perl Monks concerning the following question:
So, it will pull the first 3 tweets and put them in there, but stops at 4. Without the SQL statement it prints the values on the command line. Thank for the help in advance guys! The error I get isCREATE TABLE tweets ( id int unsigned not null PRIMARY KEY auto_increment, published blob, content blob, link blob );
You have an error in your SQL Syntax; check the manual that correspond +s with your MYSQL server version to use near 's Nuclear Security Summ +it -- focusing on solutions top keep nuclear materials away
#!/usr/bin/perl use warnings; use strict; use XML::RSS; use LWP::Simple; use DBI; my $user="root"; my $password="root"; my $database="forex"; # Connect to the database. my $dbh = DBI->connect("DBI:mysql:database=forex;host=localhost", "root", "root", {'RaiseError' => 1}); # Get the source file my $source = get("http://twitter.com/statuses/user_timeline/813286.rss +"); # Create a new XML:RSS object my $rss = new XML::RSS (version => '2.0'); # Parse the file into the XML::RSS object $rss->parse($source); # For example print titles and links of each RSS item foreach my $item (@{$rss->{'items'}}) { my $published = $item->{'pubDate'}; my $content = $item->{'title'}; my $link = $item->{'link'}; #print $published . "\n"; #print $content . "\n"; #print $link . "\n\n"; my $sth=$dbh->prepare("INSERT INTO tweets (published, content, link) V +ALUES ('$published', '$content', '$link')"); $sth->execute(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tweets to a database
by MidLifeXis (Monsignor) on Apr 15, 2010 at 16:31 UTC | |
|
Re: Tweets to a database
by toolic (Bishop) on Apr 15, 2010 at 16:26 UTC | |
by JavaFan (Canon) on Apr 15, 2010 at 16:46 UTC | |
by gbotzz (Novice) on Apr 15, 2010 at 16:29 UTC |