mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Add database setup code
This commit is contained in:
parent
58f8e65669
commit
e018aead0e
1 changed files with 32 additions and 0 deletions
32
get_incidents.py
Normal file
32
get_incidents.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# This file contains the logic that periodically fetches all pages on the
|
||||
# Reachout Berlin homepage, checks if they're already in the database and inserts
|
||||
# them if needed.
|
||||
|
||||
import sqlite3
|
||||
from scraper.scraper import Scraper
|
||||
|
||||
# scraper = Scraper()
|
||||
# articles = scraper.scrape()
|
||||
|
||||
conn = sqlite3.connect('violence.db')
|
||||
c = conn.cursor()
|
||||
|
||||
# setup database schema
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS incidents (
|
||||
incident_id INTEGER PRIMARY KEY,
|
||||
date TEXT,
|
||||
place TEXT,
|
||||
additional_place TEXT,
|
||||
description TEXT
|
||||
);
|
||||
''')
|
||||
|
||||
c.execute('''
|
||||
CREATE INDEX IF NOT EXISTS incidents_date
|
||||
ON incidents (date);
|
||||
''')
|
||||
|
||||
# insert articles
|
||||
# for article in articles:
|
||||
# pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue