SQLAlchemy - Different counts of list with same queries? [duplicate]
This question already has an answer here:
sqlalchemy different value from `len(query.all())` and `query.count()`
1 answer
SQLAlchemy - only one result being returned when count() says there are more
1 answer
is possible to get two different counts of list from same query with filters?
First query:
subjects = Subject.query.filter(
and_(
...
...
).order_by(Subject.name).slice(0, 10).count()
#
print('count', subjects)
count 10
Second query:
subjects = Subject.query.filter(
and_(
...(same filters)
...
).order_by(Subject.name).slice(0, 10).all()
#
print('len', len(subjects))
len 6
(Of course, DB is same.)
Hm, do you have idea whats wrong?
python sqlalchemy
marked as duplicate by PM 2Ring
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
sqlalchemy different value from `len(query.all())` and `query.count()`
1 answer
SQLAlchemy - only one result being returned when count() says there are more
1 answer
is possible to get two different counts of list from same query with filters?
First query:
subjects = Subject.query.filter(
and_(
...
...
).order_by(Subject.name).slice(0, 10).count()
#
print('count', subjects)
count 10
Second query:
subjects = Subject.query.filter(
and_(
...(same filters)
...
).order_by(Subject.name).slice(0, 10).all()
#
print('len', len(subjects))
len 6
(Of course, DB is same.)
Hm, do you have idea whats wrong?
python sqlalchemy
marked as duplicate by PM 2Ring
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
Can you provide an example that reproduces the issue?
– SuperShoot
Nov 15 '18 at 9:08
2
This is a fairly common question. Here are some dupe candidates/related Q/A: stackoverflow.com/questions/32435346/…, stackoverflow.com/questions/52704961/…
– Ilja Everilä
Nov 15 '18 at 9:54
stackoverflow.com/questions/6933478/…
– Ilja Everilä
Nov 15 '18 at 10:00
@Ilja Everilä thanks for your hint. Now it works fine. Please, add your comment as Answer and i will accept it.
– lukassliacky
Nov 19 '18 at 15:57
add a comment |
This question already has an answer here:
sqlalchemy different value from `len(query.all())` and `query.count()`
1 answer
SQLAlchemy - only one result being returned when count() says there are more
1 answer
is possible to get two different counts of list from same query with filters?
First query:
subjects = Subject.query.filter(
and_(
...
...
).order_by(Subject.name).slice(0, 10).count()
#
print('count', subjects)
count 10
Second query:
subjects = Subject.query.filter(
and_(
...(same filters)
...
).order_by(Subject.name).slice(0, 10).all()
#
print('len', len(subjects))
len 6
(Of course, DB is same.)
Hm, do you have idea whats wrong?
python sqlalchemy
This question already has an answer here:
sqlalchemy different value from `len(query.all())` and `query.count()`
1 answer
SQLAlchemy - only one result being returned when count() says there are more
1 answer
is possible to get two different counts of list from same query with filters?
First query:
subjects = Subject.query.filter(
and_(
...
...
).order_by(Subject.name).slice(0, 10).count()
#
print('count', subjects)
count 10
Second query:
subjects = Subject.query.filter(
and_(
...(same filters)
...
).order_by(Subject.name).slice(0, 10).all()
#
print('len', len(subjects))
len 6
(Of course, DB is same.)
Hm, do you have idea whats wrong?
This question already has an answer here:
sqlalchemy different value from `len(query.all())` and `query.count()`
1 answer
SQLAlchemy - only one result being returned when count() says there are more
1 answer
python sqlalchemy
python sqlalchemy
edited Nov 15 '18 at 9:11
SuperShoot
1,855720
1,855720
asked Nov 15 '18 at 8:36
lukassliackylukassliacky
171214
171214
marked as duplicate by PM 2Ring
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by PM 2Ring
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 15 '18 at 11:09
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
2
Can you provide an example that reproduces the issue?
– SuperShoot
Nov 15 '18 at 9:08
2
This is a fairly common question. Here are some dupe candidates/related Q/A: stackoverflow.com/questions/32435346/…, stackoverflow.com/questions/52704961/…
– Ilja Everilä
Nov 15 '18 at 9:54
stackoverflow.com/questions/6933478/…
– Ilja Everilä
Nov 15 '18 at 10:00
@Ilja Everilä thanks for your hint. Now it works fine. Please, add your comment as Answer and i will accept it.
– lukassliacky
Nov 19 '18 at 15:57
add a comment |
2
Can you provide an example that reproduces the issue?
– SuperShoot
Nov 15 '18 at 9:08
2
This is a fairly common question. Here are some dupe candidates/related Q/A: stackoverflow.com/questions/32435346/…, stackoverflow.com/questions/52704961/…
– Ilja Everilä
Nov 15 '18 at 9:54
stackoverflow.com/questions/6933478/…
– Ilja Everilä
Nov 15 '18 at 10:00
@Ilja Everilä thanks for your hint. Now it works fine. Please, add your comment as Answer and i will accept it.
– lukassliacky
Nov 19 '18 at 15:57
2
2
Can you provide an example that reproduces the issue?
– SuperShoot
Nov 15 '18 at 9:08
Can you provide an example that reproduces the issue?
– SuperShoot
Nov 15 '18 at 9:08
2
2
This is a fairly common question. Here are some dupe candidates/related Q/A: stackoverflow.com/questions/32435346/…, stackoverflow.com/questions/52704961/…
– Ilja Everilä
Nov 15 '18 at 9:54
This is a fairly common question. Here are some dupe candidates/related Q/A: stackoverflow.com/questions/32435346/…, stackoverflow.com/questions/52704961/…
– Ilja Everilä
Nov 15 '18 at 9:54
stackoverflow.com/questions/6933478/…
– Ilja Everilä
Nov 15 '18 at 10:00
stackoverflow.com/questions/6933478/…
– Ilja Everilä
Nov 15 '18 at 10:00
@Ilja Everilä thanks for your hint. Now it works fine. Please, add your comment as Answer and i will accept it.
– lukassliacky
Nov 19 '18 at 15:57
@Ilja Everilä thanks for your hint. Now it works fine. Please, add your comment as Answer and i will accept it.
– lukassliacky
Nov 19 '18 at 15:57
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
2
Can you provide an example that reproduces the issue?
– SuperShoot
Nov 15 '18 at 9:08
2
This is a fairly common question. Here are some dupe candidates/related Q/A: stackoverflow.com/questions/32435346/…, stackoverflow.com/questions/52704961/…
– Ilja Everilä
Nov 15 '18 at 9:54
stackoverflow.com/questions/6933478/…
– Ilja Everilä
Nov 15 '18 at 10:00
@Ilja Everilä thanks for your hint. Now it works fine. Please, add your comment as Answer and i will accept it.
– lukassliacky
Nov 19 '18 at 15:57