1\name{search_twitter_and_store}
2\alias{search_twitter_and_store}
3\title{
4A function to store searched tweets to a database
5}
6\description{
7A convenience function designed to wrap the process of running a twitter search and pushing the results to a database.
8If this is called more than once, the search will start with the most recent tweet already stored.
9}
10\usage{
11search_twitter_and_store(searchString, table_name = "tweets", lang = NULL,
12  locale = NULL, geocode = NULL, retryOnRateLimit = 120, ...)
13}
14\arguments{
15  \item{searchString}{The search string to use, e.g. as one would in \code{\link{searchTwitter}}}
16  \item{table_name}{The database to store the tweets to, see \code{\link{register_db_backend}}}
17  \item{lang}{If not \code{NULL}, restricts tweets to the given
18    language, given by an ISO 639-1 code}
19  \item{locale}{If not \code{NULL}, will set the locale for the search.
20    As of 03/06/11 only \code{ja} is effective, as per the Twitter API}
21  \item{geocode}{If not \code{NULL}, returns tweets by users located
22    within a given radius of the given latitude/longitude. See
23    \code{Details} in \code{link{searchTwitter}}}
24  \item{retryOnRateLimit}{If non-zero the search command will block retry up to
25    X times if the rate limit is experienced. This might lead to a much longer run
26    time but the task will eventually complete if the retry count is high enough}
27  \item{...}{Optional arguments to be passed to \code{\link{GET}}}
28}
29\details{
30All arguments but \code{table_name} are being passed directly to \code{\link{searchTwitter}}.
31
32This function will check if \code{table_name} exists, and if so will also use a \code{sinceID} of the
33most recent ID in the table. The search is performed, the returned tweets are stored
34in the database via \code{\link{store_tweets_db}}.
35}
36\value{
37The number of tweets stored
38}
39\note{Jeff Gentry}
40\seealso{
41\code{\link{register_db_backend}}, \code{\link{searchTwitter}}, \code{\link{store_tweets_db}}
42}
43\examples{
44  \dontrun{
45       register_sqlite_backend("sqlit_file")
46       n = search_twitter_and_store("#rstats", "rstats_tweets")
47  }
48}
49\keyword{ utilities }