Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add human-readable table output mode #1262

Merged
merged 2 commits into from
Dec 26, 2021
Merged

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Dec 24, 2021

By submitting this pull request, I confirm the following:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


A small Christmas present 🎄: pihole-FTL sqlite3 -h ...

Normal table printing:

$ pihole-FTL sqlite3 /etc/pihole/pihole-FTL.db "SELECT * FROM network_addresses LIMIT 2"
19|169.254.48.28|1610737320||
20|169.254.157.55|1610737320||

New human-readable output (added -h):

$ pihole-FTL sqlite3 -h /etc/pihole/pihole-FTL.db "SELECT * FROM network_addresses LIMIT 2"
network_id  ip              lastSeen    name    nameUpdated
----------  --------------  ----------  ------  -----------
19          169.254.48.28   1610737320  (null)  (null)     
20          169.254.157.55  1610737320  (null)  (null)

This also works in interactive mode:

$ pihole-FTL sqlite3 -h /etc/pihole/pihole-FTL.db

Pi-hole FTL v5.11-51-g3511341f-dirty
SQLite version 3.37.0 2021-11-27 14:13:22
Enter ".help" for usage hints.

sqlite> SELECT * FROM network_addresses LIMIT 2;
network_id  ip              lastSeen    name    nameUpdated
----------  --------------  ----------  ------  -----------
19          169.254.48.28   1610737320  (null)  (null)     
20          169.254.157.55  1610737320  (null)  (null)

sqlite>

and even without specifying any database at all:

$ pihole-FTL sqlite3 -h

Pi-hole FTL v5.11-51-g3511341f-dirty
SQLite version 3.37.0 2021-11-27 14:13:22
Enter ".help" for usage hints.

sqlite> CREATE TABLE a (first,second);

sqlite> INSERT INTO a VALUES (1,2);

sqlite> SELECT * FROM a;
first  second
-----  ------
1      2

sqlite>

It works by calling the SQLite3 shell with the options -column -header -nullvalue (null) automatically enabled without the user having to enter them manually.

@yubiuser
Copy link
Member

Nice gift. You may want to add -h to the help text as well so it can be found. Its Christmas, not Eastern... 😉

Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Santa Claus is coming to town...

@DL6ER DL6ER changed the base branch from master to development December 26, 2021 09:38
@DL6ER DL6ER merged commit 106ef8c into development Dec 26, 2021
@DL6ER DL6ER deleted the new/human_readable_tables branch December 26, 2021 09:39
@PromoFaux PromoFaux mentioned this pull request Jan 4, 2022
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-13-web-v5-10-and-core-v5-8-released/52254/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants