Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos.core
Commits
ec632b51
Commit
ec632b51
authored
Sep 18, 2017
by
Hardik Juneja
Committed by
Rafael Monnerat
Sep 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group by to the queries using select function in collect/db.py
parent
9ed841e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
slapos/collect/db.py
slapos/collect/db.py
+3
-1
No files found.
slapos/collect/db.py
View file @
ec632b51
...
@@ -291,7 +291,7 @@ class Database:
...
@@ -291,7 +291,7 @@ class Database:
for
table
in
table_list
:
for
table
in
table_list
:
self
.
_execute
(
update_sql
%
(
table
,
date_scope
))
self
.
_execute
(
update_sql
%
(
table
,
date_scope
))
def
select
(
self
,
table
,
date
=
None
,
columns
=
"*"
,
where
=
None
,
order
=
None
,
limit
=
0
):
def
select
(
self
,
table
,
date
=
None
,
columns
=
"*"
,
where
=
None
,
order
=
None
,
group
=
None
,
limit
=
0
):
""" Query database for a full table information """
""" Query database for a full table information """
if
date
is
not
None
:
if
date
is
not
None
:
where_clause
=
" WHERE date = '%s' "
%
date
where_clause
=
" WHERE date = '%s' "
%
date
...
@@ -303,6 +303,8 @@ class Database:
...
@@ -303,6 +303,8 @@ class Database:
where_clause
+=
" WHERE 1 = 1 "
where_clause
+=
" WHERE 1 = 1 "
where_clause
+=
" AND %s "
%
where
where_clause
+=
" AND %s "
%
where
select_sql
=
"SELECT %s FROM %s %s "
%
(
columns
,
table
,
where_clause
)
select_sql
=
"SELECT %s FROM %s %s "
%
(
columns
,
table
,
where_clause
)
if
group
is
not
None
:
select_sql
+=
" GROUP BY %s"
%
group
if
order
is
not
None
:
if
order
is
not
None
:
select_sql
+=
" ORDER BY %s"
%
order
select_sql
+=
" ORDER BY %s"
%
order
if
limit
:
if
limit
:
...
...
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