1 | from django.core.management import setup_environ
|
---|
2 | import settings
|
---|
3 | setup_environ(settings)
|
---|
4 |
|
---|
5 | from django.contrib.auth.models import User
|
---|
6 |
|
---|
7 | for result in User.objects.extra(select=
|
---|
8 | {'foo3': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.username = %s)"}
|
---|
9 | , select_params=['root']).extra(select=
|
---|
10 | {'foo2': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.id = %s)"}
|
---|
11 | , select_params=['1']):
|
---|
12 | print result.foo3
|
---|
13 | for result in User.objects.extra(select=
|
---|
14 | {'foo1': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.username = %s)"}
|
---|
15 | , select_params=['root']).extra(select=
|
---|
16 | {'foo2': "SELECT COUNT(auth_user.id) FROM auth_user WHERE (auth_user.id = %s)"}
|
---|
17 | , select_params=['1']):
|
---|
18 | print result.foo1
|
---|