-
Notifications
You must be signed in to change notification settings - Fork 417
Description
Having trouble with data, code, or exercises in Practical SQL, 1st Edition? I'm glad to help. Please answer these questions, and I'll typically reply within one to two business days.
Please include the chapter number in your issue title. For example: "Chapter 13: Regular Expression Question"
General
Please answer all of these as they're essential for troubleshooting.
What's your operating system (e.g. Windows 10, macOS Catalina, Ubuntu, etc.)?
Windows 10
Did you install PostgreSQL and pgAdmin according to the steps on page xxviii of the book's Introduction? If not, please describe your installation.
I have.
Which versions of PostgreSQL and pgAdmin 4 are you using? If you aren't sure, for PostgreSQL run the SQL command SELECT version(); and for pgAdmin 4, navigate to "About pgAdmin 4" under the "Help" menu.
PostgreSQL 14.1, pgAdmin 4 version 6.1
Did you download the book's code examples and data from GitHub using the directions on page xxvii of the Introduction? If not, please describe how you loaded the material on your computer.
Yes
Issue or Question
Chapter, page and code listing number:
Chapter 15, Code listing 15-15
Describe the issue or your question:
My issue is primarily with the Python program which had been a bit of a nightmare from the get-go. Currently the issue is that every time I try to execute the function in the listing (or anything ending with LANGUAGE plpython3u since I am using Python3) I get the error below.
My steps to get here: originally Python didn't seem to be installed, so I reran the EDB language pack installer and ran the StackBuilder installer selecting Language Pack version 2. Everything went smoothly from there and I was able to import Python through CREATE EXTENSION plpython3u. However afterwards when attempting to run the function creation above, I get the error below. I have scoured multiple forums and reporting sites, and have done the following.
First, I checked in the directory C:\Program Files\PostgreSQL\14\doc\installation-notes.html to see the language version compatibility. For PostgreSQL 14 it is Python 3.9, and that is both the version installed by the language pack as well as the default on my system (separately installed from the Python website for previous projects). Originally the error was that a python3.dll module could not be found. I solved this by copying the python39.dll from the default language pack directory C:\edb\languagepack\v2\Python-3.9\python39.dll to C:\Windows\System32\ and that seemed to do the trick. However then came the current connection closed error message below (which keeps on reappearing even after you press Continue). I searched a bit online and tried to add the EDB Language Pack directory mentioned above for python to a new System Variable called PYTHONHOME to no avail. I also added the Language Pack directory and %PYTHONHOME% to my PATH variable. Again nothing. At this point I have probably spent too many hours debugging instead of SQL, and would appreciate any help from anyone who has successfully managed to use Python in their SQL system. Thanks again.
Please paste the code and error message here. It's OK to alter identifying info such as a folder name
The application has lost the database connection:
⁃ If the connection was idle it may have been forcibly disconnected.
⁃ The application server or database server may have been restarted.
⁃ The user session may have timed out.
Do you want to continue and establish a new session?