This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDB.py
65 lines (45 loc) · 1.59 KB
/
DB.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
from datetime import datetime
from pathlib import Path
import peewee
DB_PATH = Path(os.getenv('DATA_DIR', '.')) / 'voice_cache.sqlite'
database = peewee.SqliteDatabase(str(DB_PATH))
class BaseModel(peewee.Model):
class Meta:
database = database
class Prefix(BaseModel):
server_id = peewee.BigIntegerField(primary_key=True)
prefix_char = peewee.CharField(max_length=10)
class ServerSpeaker(BaseModel):
server_id = peewee.BigIntegerField(primary_key=True)
speaker = peewee.CharField()
class UserServerSpeaker(peewee.Model):
"""
Holds the data about custom speakers for users in per server way
"""
server_id = peewee.BigIntegerField()
user_id = peewee.BigIntegerField()
speaker = peewee.CharField()
class Meta:
database = database
primary_key = peewee.CompositeKey('server_id', 'user_id')
class SynthesisErrors(peewee.Model):
speaker = peewee.CharField()
text = peewee.TextField()
timestamp = peewee.DateTimeField(default=datetime.now)
class Meta:
database = database
primary_key = peewee.CompositeKey('speaker', 'text')
class SoundCache(peewee.Model):
text = peewee.TextField()
speaker = peewee.CharField()
audio = peewee.BlobField()
usages = peewee.IntegerField(default=1)
class Meta:
database = database
primary_key = peewee.CompositeKey('speaker', 'text')
Prefix.create_table()
ServerSpeaker.create_table()
SynthesisErrors.create_table()
SoundCache.create_table()
UserServerSpeaker.create_table()