Use peewee as model and rewrite the code

This commit is contained in:
Arne Schlüter 2014-12-10 23:56:15 +01:00
commit c1ac5e5ed4
5 changed files with 49 additions and 53 deletions

23
models.py Normal file
View file

@ -0,0 +1,23 @@
from peewee import *
db = SqliteDatabase('violence.db')
class BaseModel(Model):
class Meta:
database = db
class Article(BaseModel):
"""
An article is a single incident as crawled from the reach-out webpage
"""
date = DateField(index=True)
month_only = BooleanField(default=False)
place = CharField()
additional_place = CharField(null=True)
description = TextField()
hash = BlobField(index=True)
# Set up the tables
def create_tables():
database.connect()
database.create_tables([Article])