📜 ⬆️ ⬇️

Queries to the Twitter API on SQL syntax

The query language TweeQL is modeled on SQL syntax and makes working with the tweet database as easy as with a relational database.

TweeQL has the following syntax:

SELECT field1, field2 FROM streams WHERE filter_conditions GROUP BY field3, field4 WINDOW x seconds 

For example, a query like
')
 SELECT text FROM twitter_sample WHERE text contains 'bobuk'; 

it just pulls out from the stream of tweets those fragments in which 'bobuk' is mentioned (bobuk is here just for the sake of example as the most active user of the Twitter API in Runet).

All this without having to think about all the details for the right API request.

TWITTER_SAMPLE is a tweet stream that contains approximately 1% of the total. If you need to query the shared stream, specify TWITTER as the data source.

Filtered tweets can be saved to a database on a local disk (its parameters are set in settings.py). For performance reasons, writing to the database is performed only when 1000 records are reached, so if the filtered records are smaller, they will not be saved.

TweeQL is encoded in Python.

Source: https://habr.com/ru/post/107186/


All Articles