Skip to content

ManufakturaElfov/gt2db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gt2db

Collects Google Trends into a database.

Setup

Clone this repository

Requirement: git

git clone https://github.com/ManufakturaElfov/gt2db.git /opt/gt2db

Create a PostgreSQL database

Requirement: postgresql

createuser -W gt
createdb -O gt gt

Import SQL schema

psql -h 127.0.0.1 -U gt gt < /opt/gt2db/schema.sql

Create a Python VEnv

Requirement: python3-venv

python3 -m venv /opt/gt2db/venv

Install gt2db there

Requirements:

  • gcc
  • python3-dev
  • libpq-dev
bash
. /opt/gt2db/venv/bin/activate
cd /opt/gt2db
python3 setup.py install
exit

Integrate gt2db into systemd

cat <<EOF >/etc/systemd/system/gt2db.service
[Unit]
After=postgresql.service

[Service]
Type=notify
Environment=DB=postgresql://gt:[email protected]/gt
ExecStart=/bin/bash -ec '. /opt/gt2db/venv/bin/activate; exec python3 -m gt2db.daemon'
User=nobody
Group=nogroup
Restart=always

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload

Start gt2db

systemctl enable gt2db
systemctl start gt2db

Usage

Connect to the database

psql -h 127.0.0.1 -U gt gt

Insert the desired keywords

INSERT INTO keyword(keyword) VALUES ('Лилия Чанышева')
ON CONFLICT ON CONSTRAINT keyword_uk_keyword DO NOTHING;

Watch the searches table

SELECT time, searches FROM searches WHERE keyword=
(SELECT id FROM keyword WHERE keyword='Лилия Чанышева');

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages