Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
bom_identify
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
685f4117
authored
Jul 23, 2021
by
陈森彬
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加mongo类
parent
1bed00a1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
utils/mongo_opera.py
utils/mongo_opera.py
0 → 100644
View file @
685f4117
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import
pymongo
from
config
import
get_mongo_conf
from
urllib.parse
import
quote_plus
class
MongoOperator
:
def
__init__
(
self
):
config
=
get_mongo_conf
()
uri
=
'mongodb://
%
s:
%
s@
%
s/
%
s'
%
(
quote_plus
(
config
[
'user'
]),
quote_plus
(
config
[
'password'
]),
config
[
'host'
],
config
[
'database'
])
self
.
conn
=
pymongo
.
MongoClient
(
uri
)
self
.
db
=
self
.
conn
[
config
[
'database'
]]
self
.
collection
=
self
.
db
[
"spu"
]
def
find_goods_data
(
self
,
data
):
return
self
.
collection
.
aggregate
([{
'$match'
:
{
"$or"
:
data
}},
{
"$group"
:
{
"_id"
:
"$spu_name"
,
"num_tutorial"
:
{
"$sum"
:
1
}}}])
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