

# use the fetchall() method to return a list of all the data # use the execute() method to put table data into cursor obj # pass the identifier to the Identifier() method # use sql.SQL() to prevent SQL injection attacks # function that returns PostgreSQL records Print ( "PostgreSQL Connect() ERROR:", err ) # font.render(text, antialias, color, background=None) -> Surface # size of button changes depending on length of text # default font color for buttons/labels is whiteĭef _init_ ( self, name, loc, color =white ):

# selected button (will have outline rect)

# create a class for the buttons and labels # change these globals to match your settings # set the DB name, table, and table data to 'None' # import the psycopg2 database adapter for PostgreSQL Here’s how to install Pygame for Python 3: Use the pip3 command to install the package libraries for the code in these articles.Install the Pygame library using Python’s PIP3 package manager

Use the python3 -V and pip3 -V commands in a terminal or command prompt window to check if Python 3 and PIP are installed by having them return their respective version numbers. You’ll need to have Python 3 and the PIP3 package manager for Python installed on your machine before you can install the pygame and psycopg2 Python libraries.Prerequisites to creating a PostgreSQL GUI application using Pygame This article will provide example code that can assist you in setting up the Pygame application, and how you can create a few Psycopg2 Python functions that will display the PostgreSQL database’s table data on the Pygame surface. This two-part article series will demonstrate how you can use the psycopg2 Python adapter for PostgreSQL to make a simple query GUI desktop application, with Pygame, using only 300 lines of code. It’s an easy and simple way to create games, and other GUI applications, for Window, macOS, and Linux operating systems. The Pygame library distribution for Python is essentially a wrapper for the SDL (Simple Directmedia Layer) written in the C and C++ programming languages. Introduction to creating a PostgreSQL GUI app in Python
