Skip to content

Commit

Permalink
Constrained relations index
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Bilenko committed Feb 5, 2024
1 parent cac6bc3 commit 4b0a25c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions chronoscope/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ class attr(T):
name = p.TextField()
val = p.TextField()

class relation(T):
class relation(p.Model):
orig = p.IntegerField()
dest = p.IntegerField()
type = p.TextField()

class Meta:
database = db
primary_key = p.CompositeKey("orig", "dest")


TABLES = [tick, attr, relation]

Expand All @@ -57,7 +61,7 @@ def close():

def mkidx():
db.execute_sql("CREATE INDEX tick_idx on tick(id);")
db.execute_sql("CREATE INDEX relation_idx on relation(orig);")
db.execute_sql("CREATE INDEX relation_idx on relation(orig,dest);")
db.execute_sql("CREATE INDEX attr_idx on attr(id);")

def line_nr(file: str) -> int:
Expand Down

0 comments on commit 4b0a25c

Please # to comment.