Create Your Own Tweets From Your Database With The db2twitter Bot

You have an application using a database and would like to send messages to Twitter with information from this database but your app does not manage this use case.

db2twitter connects to your database, extract the data, format the result and send it to Twitter. db2twitter runs with every kind of databases supported by the SQLAlchemy Python library.

Tweet when you have a new comment in WordPress

Here is a simple example. You can not install any plugin for your WordPress and wish to send tweets as soon as a new comment is identified. Here is the full example you need to start your discovery of db2twitter !

Lets start by creating our needed configuration:

tweet={} just posted a comment on my blog. Thanks!



Now let’s install db2twitter with the Pip command:

# pip3 install db2twitter

We create a dedicated user for db2twitter to safely manipulate your data:

# adduser --home /var/lib/db2twitter --gecos "" db2twitter

Now create a /etc/db2twitter directory to store your db2twitter  configuration. Next configure the good permissions of the directory and file:

# mkdir -p /etc/db2twitter
# vim /etc/db2twitter/db2twitter.ini
# chown db2twitter:root /etc/db2twitter/db2twitter.ini
# chmod 640 /etc/db2twitter/db2twitter.ini

Now let’s add a line in your /etc/crontab in order to execute db2twitter on a regular basis:

*/10 * * * * db2twitter db2twitter /etc/db2twitter/db2twitter.ini

We’re all set! Now db2twitter will automatically retrieve your data from your wordpress database and tweet any new comment directly to your Twitter account!

More information about db2twitter

…and finally

You can help the Retweet Bot by donating anything through Liberaypay (also possible with cryptocurrencies) Even cents. That’s a big factor motivation 😉

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *