Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lzzzzl
/
param_data
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f7773e9a
authored
Nov 10, 2020
by
lzzzzl
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新attr_values mongo处理
parent
d8769c5d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
upload/param_mongo.py
upload/param_mongo.py
View file @
f7773e9a
...
...
@@ -10,8 +10,8 @@ user = parse.quote_plus("ichunt")
# pwd = parse.quote_plus("huntmon6699")
pwd
=
parse
.
quote_plus
(
"huntmon66499"
)
#
myclient = pymongo.MongoClient("mongodb://{0}:{1}@192.168.1.237:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1".format(user, pwd))
myclient
=
pymongo
.
MongoClient
(
"mongodb://{0}:{1}@172.18.137.23:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1"
.
format
(
user
,
pwd
))
myclient
=
pymongo
.
MongoClient
(
"mongodb://{0}:{1}@192.168.1.237:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1"
.
format
(
user
,
pwd
))
#
myclient = pymongo.MongoClient("mongodb://{0}:{1}@172.18.137.23:27017/?authSource=ichunt&authMechanism=SCRAM-SHA-1".format(user, pwd))
mydb
=
myclient
[
'ichunt'
]
mycol
=
mydb
[
"spu_attrs"
]
...
...
@@ -38,12 +38,13 @@ class ParamMongo(object):
for
row
in
data
:
try
:
spu_id
=
row
[
0
]
attr_values
=
str
(
json
.
loads
(
row
[
1
]))
.
split
(
","
)
attr_values
=
json
.
loads
(
row
[
1
]
)
new_av_list
=
list
()
for
av
in
attr_values
:
attr_name
=
self
.
mysql_handler
.
get_attr_name
(
av
[
0
])
attr_value
=
self
.
mysql_handler
.
get_attr_value
(
av
[
1
])
attr_unit
=
self
.
mysql_handler
.
get_attr_unit
(
av
[
2
])
for
vals
in
attr_values
:
val
=
str
(
vals
)
.
split
(
","
)
attr_name
=
self
.
mysql_handler
.
get_attr_name
(
val
[
0
])
attr_value
=
self
.
mysql_handler
.
get_attr_value
(
val
[
1
])
attr_unit
=
self
.
mysql_handler
.
get_attr_unit
(
val
[
2
])
if
attr_name
and
attr_value
and
attr_unit
:
new_av_list
.
append
({
'attr_name'
:
attr_name
,
'attr_value'
:
attr_value
,
'attr_unit'
:
attr_unit
})
self
.
search_mongo
(
spu_id
,
new_av_list
)
...
...
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