Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
R
Rule Engine Service
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
brooklyn
Rule Engine Service
Commits
033ecca1
Commit
033ecca1
authored
Oct 19, 2022
by
Sarah Abrishami
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: added db structure and make_db.py
parent
d4755b70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
app/models.py
app/models.py
+28
-0
make_db.py
make_db.py
+13
-0
No files found.
app/models.py
0 → 100644
View file @
033ecca1
from
app
import
db
from
sqlalchemy.dialects.postgresql
import
JSONB
class
Ruleset
(
db
.
Model
):
__tablename__
=
'project'
uid
=
db
.
Column
(
db
.
String
,
primary_key
=
True
)
created_date
=
db
.
Column
(
db
.
DateTime
)
modified_date
=
db
.
Column
(
db
.
DateTime
)
query
=
db
.
Column
(
db
.
String
)
connection_string
=
db
.
Column
(
db
.
String
)
rule_groups
=
db
.
Column
(
JSONB
)
def
__repr__
(
self
):
return
f
'<Ruleset {self.uid}>'
def
from_dict
(
self
,
dct
):
for
field
in
[
'uid'
,
'created_date'
,
'modified_date'
,
'query'
,
'connection_string'
,
'rule_group'
]:
if
field
in
dct
:
setattr
(
self
,
field
,
dct
[
field
])
def
to_dict
(
self
,
keys
=
[
'uid'
,
'created_date'
,
'modified_date'
,
'connection_string'
,
'query'
,
'rule_groups'
]):
dct
=
{
'uid'
:
self
.
n_metadata
,
'created_date'
:
self
.
created_date
,
'connection_string'
:
self
.
connection_string
,
'modified_date'
:
self
.
modified_date
,
'query'
:
self
.
query
,
'rule_groups'
:
self
.
rule_groups
}
out
=
{}
for
key
in
keys
:
out
[
key
]
=
dct
[
key
]
return
out
make_db.py
0 → 100644
View file @
033ecca1
from
flask
import
Flask
import
os
from
app
import
configs
,
db
import
app.models
app
=
Flask
(
__name__
)
config_name
=
os
.
getenv
(
'FLASK_ENV'
)
or
'default'
app
.
config
.
from_object
(
configs
[
config_name
])
db
.
init_app
(
app
)
app
.
app_context
()
.
push
()
db
.
drop_all
()
# db.create_all()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment