-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.py
23 lines (18 loc) · 780 Bytes
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-
import os
from peewee import IntegerField, CharField, BlobField, DateTimeField, Model, SqliteDatabase
from datetime import datetime
app_path = os.path.dirname(os.path.abspath(__file__))
db = SqliteDatabase(os.path.join(app_path, "data", "database.db"))
__all__ = ["ModelPycFile", "Meta"]
class ModelPycFile(Model):
id = IntegerField(primary_key=True)
description = CharField(max_length=256, null=False)
file_name = CharField(max_length=256, null=False)
file = BlobField(null=False)
create_date = DateTimeField(default=datetime.now(), null=False)
class Meta:
database = db
if not os.path.isfile(os.path.join(app_path, "data", "database.db")):
""" Create tables if not exists """
db.create_tables([ModelPycFile])