# How to Extract DNS Queries

**URL:** <https://discourse.pi-hole.net/t/how-to-extract-dns-queries/23966>\
**Category:** Help\
**Created:** [September 24, 2019, 11:16pm UTC](https://discourse.pi-hole.net/t/how-to-extract-dns-queries/23966 "2019-09-24T23:16:11Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![mikeyw64](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/m/c4cdca/32.png) [@mikeyw64](https://discourse.pi-hole.net/u/mikeyw64)\
**Post date:** [September 25, 2019, 6:06am UTC](https://discourse.pi-hole.net/t/how-to-extract-dns-queries/23966/6 "2019-09-25T06:06:33Z")

</div>

I've put together a basic method of querying the long term database that can be used as a starting point for constructing your own queries

> [@Exporting PiHole Stats for use in Excel](https://discourse.pi-hole.net/t/exporting-pihole-stats-for-use-in-excel/23726):
>
> This is the way I do it. The example below exports the date timestamp in human readable format, the domain that was looked up and the [status code](https://docs.pi-hole.net/ftldns/database/#supported-status-types) for all queries from a specific client . I am then running samba so I can retrieve the file from my laptop and open in excel so I can run it through a pivot table. Obviously this can be expanded upon as required pi@Heimdall:~ $ sqlite3 "/etc/pihole/pihole-FTL.db" SQLite version 3.27.2 2019-02-25 16:06:06 Enter ".help" for usage hints. sqlite\> .head…

---

_[View the full topic](https://discourse.pi-hole.net/t/how-to-extract-dns-queries/23966)._
