Querying Baseball data off platform project

I don’t know if this matters, but, there are two columns w/team id:

teamid text,
    team_id bigint,

But, if you look at the readme.txt file, that second team_id col doesn’t exist.

I’m a baseball fan and have looked at baseball data and I don’t know what that 2nd team_id is even referring to. :baseball:

1 Like

Maybe re-download the tables and see if that fixes the issue.

Hey man, I’m very sorry that I came out as rude. As I said, when referring to the course:

I’d like to check that out as well! I just don’t have access to it…

I don’t have Codecademy PRO, that’s why I couldn’t check your link and had to ask for the rest of your code. Sorry for not being clearer.

3 Likes

Hi all!

I was having the same issue, but I solved the problem with some command line prompts:

  1. Navigate to the folder with baseball_database.sql in the command line.
  2. Run psql -d <your-baseball-database-name> -f baseball_database.sql.

And that’s it! Now I can see all of the newly created tables without any problem in my client.

This webpage helped me solve the problem.

P.S., I’m running macOS Catalina 10.15.7 and using PostgreSQL (v. 13.0) and pgAdmin 4 (v. 4.27).

26 Likes

Hi Dav! This is helping me make great progress when I had been running into this issue for awhile now. However, when I run this, I got prompted for the password for my user but was unable to type anything. Do you know how I could add it to the original prompt so it is included?

also, if anyone who needs it, this stack overflow answer solved a problem with the psql command being recognized: https://stackoverflow.com/questions/30401460/postgres-psql-not-recognized-as-an-internal-or-external-command

5 Likes

Try adding a -U flag followed by the user that you want to open the database with? (Not sure if that’ll work!)

That is,

psql -U <username> -d <your-baseball-database-name> -f baseball_database.sql

If you’re not sure what to put for a username, or your username isn’t working, try “postgres”.

26 Likes

That solved it! Yeah ha KD so much for your help now I’m cooking

2 Likes

hey @davbyron thanks… that solved the issue

1 Like

This worked for me as well. Thank you for sharing! And thank you to everyone trying to help.

2 Likes

how is this solved on Windows 10?

Here’s how to do that in Windows 10:
1- right click on the windows (Aka “Start button”)
2- select “System” (you can reach there from: Settings - About)
3- in the right menu, click on “Advanced system settings”
4- in the window that popped, click on the bottom button that reads “Environment Variables…”
5- in the upper block, click on the variable that reads “Path” (double-click)
6- in the “Edit environment variable” click new
7- in the new line you should enter your path to \bin folder of your postgreSQL (default for version 13: “C:\Program Files\PostgreSQL\13\bin” yours might be different look it up)
8- back track with “Ok” to close all the 3 open windows.
9- now you can open cmd and enter the command @davbyron provided: psql -U <username> -d <your-baseball-database-name> -f baseball_database.sql

voila !

I hope that helps

21 Likes

Thank you for your help! I did all that and this pops up:

psql: error: baseball_database.sql: No such file or directory

or when I write the directory:

psql: error: C:/Users/Katerina/Downloads/TheBestOfBaseballAwards/TheBestOfBaseballAwards: Permission denied

2 Likes

Yep, I’m having the same problem. Wish opening the .sql file on Postbird worked…

Update: I got all the data to load. It’s been about a week since I tried, but I uninstalled postgres version 13.1 and downloaded postgres version 12.5 instead which may have been the difference (or maybe someone fixed the .sql file not sure either way it works now).

4 Likes

This worked for me. I tried some of the command line stuff with no luck. Simply downloading postgres 12.5 instead of 13 made it all work. I’m using the same SQL file, so it is the version of postgres that is the issue.

3 Likes

Hey everyone, I was facing a major problem when trying to import Baseball.sql file.
I kept getting this error “authentication method 10 not supported”.
I managed to overcome this error by using the SQL Shell (psql) provided after installing PostgreSQL and Postbird, well one of them :see_no_evil:.

  1. You have to login into the postgres user or whatever user you created
  2. connect to the database you want the data inserted too, I named mine Baseball: postgres=# \c Baseball
  3. Using the ‘\i’ command just select the past the file path for the sql file you want to import: Baseball=# \i '.../TheBestOfBaseballAwards/baseball_database.sql'.
14 Likes

Every time have error like this:
Select database ‘baseball’
ERROR:
Can not find psql in a system. Make sure PostgreSQL client is installed.
On Ubuntu/Debian - package ‘postgresql-client’
On RHEL/Fedora - package ‘postgresql’
FAILURE

Reinstalled Postbird - didn’t help
Reinstalled PostgreSQL to version 12 - didn’t help
Downloaded ‘postgresql client’ - didn’t help

Maybe it’s time to download SQLite and forget about postgres…

Thanx!! I’ve tried all the other options and didn’t work,. I didn’t want to downgrade postgres as it is suggested above… but your method did the trick! You are awesome!
(I work on windows10, postgres13)

I did everything @siger212 said and it worked for me. Make sure you close your cmd window and reopen it prior to running the final command that @davbyron provided. I also work on Windows 10, thanks for the help all!

Step one: create database “baseball” in postbird

Step 2: Watch These two videos in order:
1: 'psql' is not recognized as an internal or external command - YouTube
2: psql: error: could not connect to server: FATAL: password authentication failed for user - YouTube

1 Like