I'm not sure if this is the good place to ask this type of question.
I have the following set up:
DB_HOST=localhost
DB_PORT=5432
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ["DB_NAME"],
'USER': os.environ["DB_USER"],
'PASSWORD': os.environ["DB_PASS"],
'HOST': os.environ["DB_HOST"],
'PORT': os.environ["DB_PORT"],
},
}
and was able run a query and get the data back:
>>> from app1.models import Facility
>>> facility = Facility.objects.filter(id=32432148)
>>> print("NAME:"+facility[0].algo_name)
NAME:FBNR_LE
>>> print("FAC_ID:"+facility[0].fac_id)
FAC_ID:FBNR_LE_BNS
What I want to do is to bascally sniff the DB query packets sent from Django over to Postgresql server.
So I run tcpdump for duration of the query:
# tcpdump 'tcp port 5432' -w /tmp/tcp_dump.pcap
However, the query and the data returned from it can not be found in the output file.
Anyone have idea how I can capture and view Django query packets?
question from:
https://stackoverflow.com/questions/65941419/sniffing-django-database-query-packets 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…