mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Use peewee as model and rewrite the code
This commit is contained in:
parent
0e095dbb63
commit
c1ac5e5ed4
5 changed files with 49 additions and 53 deletions
23
models.py
Normal file
23
models.py
Normal 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])
|
||||
Loading…
Add table
Add a link
Reference in a new issue