-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
44 lines (37 loc) · 980 Bytes
/
db.py
File metadata and controls
44 lines (37 loc) · 980 Bytes
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
from peewee import (
CharField,
DateTimeField,
ForeignKeyField,
Model,
PostgresqlDatabase,
TextField,
IntegerField,
)
from pgvector.peewee import VectorField
db = PostgresqlDatabase(
user="postgres",
password="1546",
host="localhost",
port=5432,
database="postgres",
)
class BaseModel(Model):
class Meta:
database = db
class Post(BaseModel):
post_id = CharField(unique=True)
title = CharField(max_length=512)
author = CharField()
created_at = DateTimeField()
content = TextField()
score = IntegerField()
embedding = VectorField(dimensions=384)
class Comment(BaseModel):
comment_id = CharField(unique=True)
post = ForeignKeyField(Post, backref="comments")
parent = ForeignKeyField("self", null=True, backref="replies")
author = CharField()
created_at = DateTimeField()
content = TextField()
score = IntegerField()
embedding = VectorField(dimensions=384)