geohernandez
Menu
  • HOME
  • ABOUT
  • CONTACT ME
  • WORK WITH GEO
    • Data Specialist
    • Speaker Events
    • Resume
  • English
    • English
    • EspaƱol
Menu

Formatting our Postgres scripts with pgformatter in DBeaver

Posted on December 26, 2023July 6, 2024 by geohernandez

Are you a PostgreSQL enthusiast using DBeaver on a Windows Platform? If you find yourself knee-deep in SQL queries and long for a cleaner, more organized code, then configuring pgFormatter might be the solution you’re looking for. In this post, we’ll dive into the intricacies of setting up pgFormatter within DBeaver on Windows, offering you a streamlined and visually appealing SQL coding experience.

Whether you are a database administrator, developer, or a curious SQL fan, understanding how to integrate pgFormatter into your /DBeaver workflow can significantly enhance your coding efficiency. Let’s embark on this step-by-step journey to configure pgFormatter, making your SQL code more readable and consistent. Let us get started!

What is pgFormatter?

It is an open-source tool used to format SQL and PLPGSQL code, it is widely embraced by the PostgreSQL community. You can find comprehensive details about it on the official PostgreSQL site.

Note: In case you are using Mac or Linux, you can find many resources explaining how to configure SQL Formatter in DBeaver. A useful link is here.

Contents

  • Installation Prerequisites
  • Setting up pgFormatter in DBeaver
  • pgFormatter in action

Installation Prerequisites

Before diving into the use of SQL Formatter tool, you need to ensure the following components are in place:

  • Perl
  • pgformatter
  • DBeaver

First of all, it is mandatory before using SQL Formatter to configure Perl, which is the language used internally by SQL Formatter. Later, we should download SQL Formatter, copy it to a specific directory and finally do the proper configuration on DBeaver. The following sections will explain to you in detail how to do it.

Installing Perl in Windows

For Windows users, the critical first step is to install Perl, the language used internally by SQLFormatter. I recommend using Strawberry Perl, a simple and reliable package available at this link.

https://strawberryperl.com/

My recommendation is to install the System installer version, mainly because the .msi file automatically registers in the PATH. After installation, open the command line and verify the Perl version by running ‘perl -v‘

Configuring pgFormatter

The pgFormatter package is available in the next links:

  • https://github.com/darold/pgformatter

Once you have downloaded the zip file, you should extract it into a target folder, as in this example:

Setting up pgFormatter in DBeaver

At this point, we can go DBeaver and configure the use of pgFormatter as an external formatted. Go to the Windows –> Preferences –> Editors –> Formatting. Once in there, you should follow the instructions on this code:

1
perl.exe "Path_of_pg_format_package\pg_format" ${file}

It is mandatory to mark Use temp file for managing the format on the current code (highlighted). See this example:

pgFormatter in action

At this point, we are ready to start with pgFormatter inside DBeaver. The following image shows you a code without format:

You should select the code and apply the key shortcut combination: Ctrl + Shift + F. Here is the output:

Conclusion

In conclusion, this post provides a straightforward approach to enhancing the appearance of your SQL code using pgFormatter in DBeaver. The ability to customize preferences and further adapt with pgFormatter is a topic we’ll explore in future posts. Happy Coding!

Category: Uncategorized

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search for articles

Recent Posts

  • Quick Guide: BigQuery Service Account Setup Using gcloud
  • The Art of Data Modeling in AI times
  • Getting Started with Snowflake’s Snowpipe for Data Ingestion on Azure

Categories

  • Airflow (1)
  • Azure (6)
  • Azure DevOps (2)
  • Bash script (1)
  • Blog (1)
  • Cassandra (3)
  • Chronicles from the trenches (26)
  • Data Architecture (3)
  • Data Engineering (11)
  • DB optimization (2)
  • Events (2)
  • GIT (1)
  • MySQL (1)
  • Python (7)
  • Snowflake (3)
  • SQL Saturday (1)
  • SSIS (2)
  • T-SQL (5)
  • Uncategorized (2)

Archives

  • May 2025 (1)
  • March 2025 (1)
  • January 2025 (2)
  • October 2024 (1)
  • July 2024 (1)
  • May 2024 (1)
  • December 2023 (1)
  • November 2023 (1)
  • August 2023 (1)
  • June 2023 (1)
  • December 2022 (1)
  • November 2022 (1)
  • July 2022 (1)
  • March 2022 (1)
  • September 2021 (1)
  • May 2021 (1)
  • March 2021 (1)
  • February 2021 (3)
  • December 2020 (1)
  • October 2020 (3)
  • September 2020 (1)
  • August 2020 (1)
  • January 2020 (1)
  • August 2019 (1)
  • July 2019 (1)
  • June 2019 (1)
  • May 2019 (1)
  • April 2019 (1)
  • March 2019 (1)
  • November 2018 (3)
  • October 2018 (1)
  • September 2018 (1)
  • August 2018 (2)
© 2025 geohernandez | Powered by Minimalist Blog WordPress Theme