Collects Google Trends into a database.
Requirement: git
git clone https://github.com/ManufakturaElfov/gt2db.git /opt/gt2db
Requirement: postgresql
createuser -W gt
createdb -O gt gt
psql -h 127.0.0.1 -U gt gt < /opt/gt2db/schema.sql
Requirement: python3-venv
python3 -m venv /opt/gt2db/venv
Requirements:
- gcc
- python3-dev
- libpq-dev
bash
. /opt/gt2db/venv/bin/activate
cd /opt/gt2db
python3 setup.py install
exit
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
systemctl enable gt2db
systemctl start gt2db
psql -h 127.0.0.1 -U gt gt
INSERT INTO keyword(keyword) VALUES ('Лилия Чанышева')
ON CONFLICT ON CONSTRAINT keyword_uk_keyword DO NOTHING;
SELECT time, searches FROM searches WHERE keyword=
(SELECT id FROM keyword WHERE keyword='Лилия Чанышева');