Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
adda06a7
Commit
adda06a7
authored
2 months ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
make maximum insertable packet length in SQL DB configurable
use MAX_PKT_LEN in packet_config_PROJECT
parent
5db02f27
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ccs/database/tm_db.py
+16
-5
16 additions, 5 deletions
Ccs/database/tm_db.py
with
16 additions
and
5 deletions
Ccs/database/tm_db.py
+
16
−
5
View file @
adda06a7
...
...
@@ -27,6 +27,17 @@ protocols = {'PUS': ('', DB_BASE),
'
RMAP
'
:
(
'
rmap_
'
,
DB_BASE
),
'
FEEDATA
'
:
(
'
feedata_
'
,
DB_BASE
)}
# get max packet size from project
try
:
sys
.
path
.
insert
(
0
,
'
..
'
)
packet_config
=
'
packet_config_
'
+
config_db
.
cfg
.
get
(
'
project
'
,
'
name
'
).
strip
()
pcmodule
=
__import__
(
packet_config
)
MAX_PKT_LEN
=
pcmodule
.
MAX_PKT_LEN
except
Exception
as
err
:
print
(
err
)
print
(
'
Setting max. packet length to 1024
'
)
MAX_PKT_LEN
=
1024
# default max packet length
class
DbTelemetryPool
(
DB_BASE
):
# type: ignore
"""
...
...
@@ -86,8 +97,8 @@ class DbTelemetry(DB_BASE): # type: ignore
destID
=
Column
(
Integer
,
nullable
=
False
)
timestamp
=
Column
(
Unicode
(
250
,
collation
=
'
utf8_general_ci
'
),
nullable
=
True
,
index
=
True
)
# Should this be TIMESTAMP?
data
=
Column
(
VARBINARY
(
1024
),
nullable
=
False
)
# Much faster than BLOB
raw
=
Column
(
VARBINARY
(
1024
),
nullable
=
False
)
# Much faster than BLOB
data
=
Column
(
VARBINARY
(
MAX_PKT_LEN
),
nullable
=
False
)
# Much faster than BLOB
raw
=
Column
(
VARBINARY
(
MAX_PKT_LEN
),
nullable
=
False
)
# Much faster than BLOB
# Helper attribute to access the associated pool.
pool
=
relationship
(
"
DbTelemetryPool
"
)
...
...
@@ -279,14 +290,14 @@ def scoped_session_maker(db_schema, idb_version=None):
return
_engine
=
create_engine
(
gen_mysql_conn_str
(
schema
=
schema
),
echo
=
"
-v
"
in
sys
.
argv
,
pool_size
=
15
)
session_factory
=
sessionmaker
(
bind
=
_engine
)
scoped_session_factory
=
scoped_session
(
session_factory
)
#
scoped_session_factory = scoped_session_v2(session_factory)
#
scoped_session_factory = scoped_session(session_factory)
scoped_session_factory
=
scoped_session_v2
(
session_factory
)
return
scoped_session_factory
class
scoped_session_v2
(
scoped_session
):
"""
Wrapper class to cast SQL query statement string to TextClause before execution, as this is required
since
SQLAlchemy 2.0.
Wrapper class to cast SQL query statement string to TextClause before execution, as this is required
from
SQLAlchemy 2.0.
"""
def
execute
(
self
,
x
,
*
args
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment