Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
logbook-hfe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
logbook-hfe
Commits
ac23c240
You need to sign in or sign up before continuing.
Commit
ac23c240
authored
Mar 09, 2021
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated sql_db_utils
parent
4994078b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
20 deletions
+83
-20
scripts/constants/__init__.py
scripts/constants/__init__.py
+2
-2
scripts/constants/configurations.py
scripts/constants/configurations.py
+2
-2
scripts/utils/sql_db_utils.py
scripts/utils/sql_db_utils.py
+79
-16
No files found.
scripts/constants/__init__.py
View file @
ac23c240
from
scripts.constants.configurations
import
Service
,
SqlDB
,
MongoDB
,
ApplicationKeys
from
scripts.constants.configurations
import
Service
,
SqlDB
,
MongoDB
,
ApplicationKeys
,
Log
from
scripts.constants.mongoconstants
import
CommonConstants
,
MongoConstants
from
scripts.constants.mongoconstants
import
CommonConstants
,
MongoConstants
class
Conf
(
SqlDB
,
Service
,
MongoDB
,
ApplicationKeys
):
class
Conf
(
SqlDB
,
Service
,
MongoDB
,
ApplicationKeys
,
Log
):
pass
pass
...
...
scripts/constants/configurations.py
View file @
ac23c240
...
@@ -44,8 +44,8 @@ class _Configuration(BaseSettings):
...
@@ -44,8 +44,8 @@ class _Configuration(BaseSettings):
DB_PORT
:
int
=
_config
.
get
(
'DB'
,
'port'
,
fallback
=
2717
)
DB_PORT
:
int
=
_config
.
get
(
'DB'
,
'port'
,
fallback
=
2717
)
DB_USERNAME
:
str
=
_config
.
get
(
'DB'
,
'username'
,
fallback
=
None
)
DB_USERNAME
:
str
=
_config
.
get
(
'DB'
,
'username'
,
fallback
=
None
)
DB_PASSWORD
:
str
=
_config
.
get
(
'DB'
,
'password'
,
fallback
=
None
)
DB_PASSWORD
:
str
=
_config
.
get
(
'DB'
,
'password'
,
fallback
=
None
)
DB_NAME
:
str
=
_config
.
get
(
'DB'
,
'
name'
,
fallback
=
'ilens
_logbook'
)
DB_NAME
:
str
=
_config
.
get
(
'DB'
,
'
db_name'
,
fallback
=
'maintenance
_logbook'
)
SQLITE_DEFAULT_DB_PATH
:
str
=
os
.
path
.
join
(
db_folder_path
,
'
ilens
_logbook.db'
)
SQLITE_DEFAULT_DB_PATH
:
str
=
os
.
path
.
join
(
db_folder_path
,
'
maintenance
_logbook.db'
)
class
Config
:
class
Config
:
env_file
=
f
'{APP_ENV}.env'
env_file
=
f
'{APP_ENV}.env'
...
...
scripts/utils/sql_db_utils.py
View file @
ac23c240
from
sqlalchemy
import
String
,
JSON
,
Float
,
Integer
from
sqlalchemy
import
Float
,
Integer
,
ForeignKey
,
Text
from
sqlalchemy
import
create_engine
,
MetaData
,
Column
,
Table
from
sqlalchemy
import
create_engine
,
MetaData
,
Column
,
Table
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.dialects.postgresql
import
JSON
from
sqlalchemy.orm
import
relationship
from
sqlalchemy.orm
import
sessionmaker
from
sqlalchemy.orm
import
sessionmaker
from
scripts.logging.logging
import
logger
as
LOG
from
scripts.logging.logging
import
logger
as
LOG
...
@@ -9,41 +11,102 @@ from scripts.utils.common_utils import CommonUtils
...
@@ -9,41 +11,102 @@ from scripts.utils.common_utils import CommonUtils
Base
=
declarative_base
()
Base
=
declarative_base
()
class
Table
Audits
(
Base
):
class
Table
UserEntry
(
Base
):
__tablename__
=
"table_user_entry"
__tablename__
=
"table_user_entry"
template_id
=
Column
(
String
)
template_id
=
Column
(
Text
)
template_json
=
Column
(
JSON
)
template_json
=
Column
(
JSON
)
user_id
=
Column
(
String
)
user_id
=
Column
(
Text
)
last_updated
=
Column
(
Float
(
precision
=
20
,
decimal_return_scale
=
True
))
last_updated
=
Column
(
Float
(
precision
=
20
,
decimal_return_scale
=
True
))
id
=
Column
(
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
id
=
Column
(
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
template_instance_id
=
Column
(
Text
)
event_type
=
Column
(
Text
)
event_status
=
Column
(
Text
)
event_id
=
Column
(
Text
)
user_entry_actions
=
relationship
(
'UserActions'
,
back_populates
=
'user_actions'
)
@
staticmethod
@
staticmethod
def
column_template_id
():
def
column_template_id
():
return
'template_id'
return
'template_id'
@
staticmethod
def
column_event_status
():
return
'event_status'
@
staticmethod
@
staticmethod
def
column_audit_type
():
def
column_audit_type
():
return
'audit_type'
return
'audit_type'
@
staticmethod
@
staticmethod
def
column_audit_time
():
def
column_template_instance_id
():
return
'audit_time'
return
'template_instance_id'
@
staticmethod
def
column_event_type
():
return
'event_type'
@
staticmethod
def
column_event_id
():
return
'event_id'
@
staticmethod
def
column_last_updated
():
return
"last_updated"
@
staticmethod
@
staticmethod
def
column_
audit_mapping
_id
():
def
column_
user
_id
():
return
'audit_mapping_id'
return
"user_id"
@
staticmethod
@
staticmethod
def
column_
audit_message
():
def
column_
template_json
():
return
'audit_message'
return
"template_json"
def
table_def_audits
(
self
,
meta
=
MetaData
()):
@
staticmethod
def
column_id
():
return
"id"
def
table_def_user_entry
(
self
,
meta
=
MetaData
()):
return
Table
(
self
.
__tablename__
,
meta
,
return
Table
(
self
.
__tablename__
,
meta
,
Column
(
self
.
column_audit_id
(),
String
(
64
),
primary_key
=
True
),
Column
(
self
.
column_template_id
(),
Text
),
Column
(
self
.
column_audit_type
(),
String
(
64
)),
Column
(
self
.
column_template_json
(),
JSON
),
Column
(
self
.
column_audit_time
(),
BigInteger
),
Column
(
self
.
column_user_id
(),
Text
),
Column
(
self
.
column_audit_mapping_id
(),
String
(
64
)),
Column
(
self
.
column_last_updated
(),
Float
(
precision
=
20
,
decimal_return_scale
=
True
)),
Column
(
self
.
column_audit_message
(),
String
(
2048
)),
extend_existing
=
True
)
Column
(
self
.
column_event_status
(),
Text
),
Column
(
self
.
column_template_instance_id
(),
Text
),
Column
(
self
.
column_event_type
(),
Text
),
Column
(
self
.
column_event_id
(),
Text
),
Column
(
self
.
column_id
(),
Integer
,
primary_key
=
True
,
autoincrement
=
True
))
class
UserActions
(
Base
):
__tablename__
=
"user_action"
template_id
=
Column
(
String
,
ForeignKey
(
'table_user_entry.template_id'
)),
action
=
Column
(
String
)
user_id
=
Column
(
String
)
last_updated
=
Column
(
Integer
)
id
=
Column
(
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
audit_id
=
Column
(
String
)
user_actions
=
relationship
(
'TableUserEntry'
,
back_populates
=
'user_entry_actions'
)
@
staticmethod
def
column_template_id
():
return
'template_id'
@
staticmethod
def
column_action
():
return
'action'
@
staticmethod
def
column_user_id
():
return
'user_id'
@
staticmethod
def
column_last_updated
():
return
'last_updated'
@
staticmethod
def
column_audit_id
():
return
'audit_id'
class
SQLDBUtils
(
CommonUtils
):
class
SQLDBUtils
(
CommonUtils
):
...
...
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