mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add PackageBase SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
822905be7d
commit
a7e5498197
3 changed files with 103 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
import math
|
||||
|
||||
from sqlalchemy.orm import backref, relationship
|
||||
|
||||
import aurweb.config
|
||||
import aurweb.util
|
||||
|
||||
|
@ -51,6 +53,11 @@ def make_random_value(table: str, column: str):
|
|||
return string
|
||||
|
||||
|
||||
def make_relationship(model, foreign_key, backref_):
|
||||
return relationship(model, foreign_keys=[foreign_key],
|
||||
backref=backref(backref_, lazy="dynamic"))
|
||||
|
||||
|
||||
def query(model, *args, **kwargs):
|
||||
return session.query(model).filter(*args, **kwargs)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue