Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
meanspec-hwinfo-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
MeanSpec (SCE338 2024-2 Group 1)
meanspec-hwinfo-daemon
Commits
aa958ff7
Commit
aa958ff7
authored
6 months ago
by
Eunhak Lee
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/1' into 'master'
fix: 데몬이 여러 개 작동할 때 part 를 새로 생성하면서 생기는 conflict 해결 Fixed
#1
See merge request
!1
parents
8ac006fc
3e29233d
No related branches found
No related tags found
1 merge request
!1
fix: 대몬이 여러 개 작동할 때 part 를 새로 생성하면서 생기는 conflict 해결
Pipeline
#10667
passed
6 months ago
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
push_to_db.py
+5
-3
5 additions, 3 deletions
push_to_db.py
with
5 additions
and
3 deletions
push_to_db.py
+
5
−
3
View file @
aa958ff7
...
@@ -61,8 +61,10 @@ def create_new_one(_dict, part_type, _cursor):
...
@@ -61,8 +61,10 @@ def create_new_one(_dict, part_type, _cursor):
columns
=
"
,
"
.
join
([
f
'"
{
key
}
"'
for
key
,
_
in
_obj
])
columns
=
"
,
"
.
join
([
f
'"
{
key
}
"'
for
key
,
_
in
_obj
])
values
=
[
value
for
_
,
value
in
_obj
]
values
=
[
value
for
_
,
value
in
_obj
]
sql
=
"""
WITH rows AS (INSERT INTO parts (name, type) VALUES (%s, %s) RETURNING id)
sql
=
"""
WITH rows AS (INSERT INTO parts (name, type) VALUES (%s, %s) ON CONFLICT (name) DO UPDATE SET name = excluded.name RETURNING id)
INSERT INTO part_info_{type} (part_id, {columns}) (SELECT rows.id, {value_entries} FROM rows) RETURNING part_id;
"""
.
format
(
type
=
_part_type_enum
,
columns
=
columns
,
value_entries
=
"
,
"
.
join
([
"
%s
"
]
*
len
(
values
)))
INSERT INTO part_info_{type} (part_id, {columns})
(SELECT rows.id, {value_entries} FROM rows)
RETURNING part_id;
"""
.
format
(
type
=
_part_type_enum
,
columns
=
columns
,
value_entries
=
"
,
"
.
join
([
"
%s
"
]
*
len
(
values
)))
_cursor
.
execute
(
sql
,
(
name
,
_part_type_enum
,
*
values
))
_cursor
.
execute
(
sql
,
(
name
,
_part_type_enum
,
*
values
))
data
=
_cursor
.
fetchall
()
data
=
_cursor
.
fetchall
()
...
@@ -72,7 +74,7 @@ INSERT INTO part_info_{type} (part_id, {columns}) (SELECT rows.id, {value_entrie
...
@@ -72,7 +74,7 @@ INSERT INTO part_info_{type} (part_id, {columns}) (SELECT rows.id, {value_entrie
def
get_user_by_email
(
_cursor
,
_email
):
def
get_user_by_email
(
_cursor
,
_email
):
_cursor
.
execute
(
"
SELECT id FROM users WHERE email = %s;
"
,
(
_email
,))
_cursor
.
execute
(
"
SELECT id FROM users
d
WHERE email = %s;
"
,
(
_email
,))
data
=
_cursor
.
fetchall
()
data
=
_cursor
.
fetchall
()
if
data
:
if
data
:
...
...
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