-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
executable file
·34 lines (29 loc) · 875 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import peewee
import os
db_name = 'kodkast.db'
db_dir = os.path.join(os.path.expanduser('~'),'.kodkast')
if not os.path.isdir(db_dir):
os.makedirs(db_dir)
db_path = os.path.join(db_dir, db_name)
database = peewee.SqliteDatabase(db_path)
class PodcastDB(peewee.Model):
"""
A database of podcast titles, urls, and images.
"""
title = peewee.CharField()
url = peewee.CharField()
image = peewee.CharField()
class Meta:
database = database
class EpisodeDB(peewee.Model):
"""
A database of podcast ids, episode titles, publish dates, urls, images, and durations
"""
podcast = peewee.ForeignKeyField(PodcastDB)
title = peewee.CharField()
pub_date = peewee.CharField()
url = peewee.CharField()
image = peewee.CharField()
bookmark = peewee.IntegerField()
class Meta:
database = database