1 | #!venv/bin/python
|
---|
2 |
|
---|
3 | from os.path import dirname, join
|
---|
4 |
|
---|
5 | import os
|
---|
6 | import sys
|
---|
7 |
|
---|
8 | sys.path.append(join(dirname(__file__), 'mysite'))
|
---|
9 |
|
---|
10 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
|
---|
11 |
|
---|
12 | import django
|
---|
13 | django.setup()
|
---|
14 |
|
---|
15 | from django.db import connection
|
---|
16 |
|
---|
17 | cursor = connection.cursor()
|
---|
18 | cursor.execute("SELECT name FROM sqlite_master WHERE type='index' and name LIKE 'polls_%';")
|
---|
19 | indexes = cursor.fetchall()
|
---|
20 |
|
---|
21 | for index in indexes:
|
---|
22 | index_name = index[0]
|
---|
23 | cursor.execute(f"PRAGMA index_info({index_name});")
|
---|
24 | info = cursor.fetchall()
|
---|
25 | print(f"\nIndex: {index_name}")
|
---|
26 | for col in info:
|
---|
27 | print(f" Column {col[0]}: {col[2]} (cid: {col[1]})")
|
---|