-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect.py
80 lines (58 loc) · 1.5 KB
/
connect.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
''' peewee'''
from datetime import datetime
from peewee import MySQLDatabase, Model, IntegerField, CharField, DateTimeField
from pydantic import BaseModel
db = MySQLDatabase('apibd', user='root', password='lenok',
host='localhost', port=3306)
class Database(Model):
''' d'''
class Meta:
''' j'''
database = db
class Users(Database):
''' Пользователь'''
id = IntegerField(primary_key=True)
role_id = IntegerField()
username = CharField()
password = CharField()
class Roles(Database):
''' roles'''
id = IntegerField(primary_key=True)
name = CharField()
class News(Database):
''' News'''
id = IntegerField(primary_key=True)
heading = CharField()
content = CharField()
author = CharField()
data = DateTimeField(formats=['%Y-%m-%d'])
class Comments(Database):
''' Comments'''
id = IntegerField(primary_key=True)
news = CharField()
author = CharField()
content = CharField()
data = DateTimeField(formats=['%Y-%m-%d'])
db.connect()
db.create_tables([Users, Roles, News, Comments], safe=True)
db.close()
class UserUpdate(BaseModel):
''' kjkj'''
role_id: int
username: str
password: str
class RolesUpdate(BaseModel):
''' мг'''
name: str
class NewsUpdate(BaseModel):
''' lk'''
heading: str
content: str
author: str
data: datetime
class CommentUpdate(BaseModel):
''' kj'''
news: str
author: str
content: str
data: datetime