Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMohammed Safa
639 PointsDownload sql File
Where can i get the .sql file or the database file to practice this locally in my phpmyadmin ? Thanks
Luke Ayres
2,971 PointsI think this is a great question, it's a shame nobody has answered it. Did you find anything out on your own?
2 Answers
Adam Fields
Full Stack JavaScript Techdegree Graduate 37,838 PointsI'm using PostgreSQL and here is my solution. Each table takes about a minute to import. You will need to know how to use Terminal, how to install software (in this case PostgreSQL), and how to start a service (the PostgreSQL server must be running). There are plenty of guides on the internet to get you started.
- In Treehouse Playground, copy the entire table.
- In your text editor, create a new file and save it as a CSV (e.g., books.csv). Paste your clipboard.
- Do a find and replace to replace the tab stops with commas (tab stops look like an arrow in a text editor if you have show invisible characters turned on).
- Start a postgres shell session and connect to the default database:
psql postgres
- Create a database called treehouse from the Postgres shell
CREATE DATABASE treehouse;
- Connect to the treehouse database from the Postgres shell:
\connect treehouse
- Create a books table from the Postgres shell:
CREATE TABLE books (id INT PRIMARY KEY, title TEXT, author TEXT, genre TEXT, first_published TEXT);
- Import your CSV:
COPY books (id, title, author, genre, first_published)
FROM '/Users/username/Desktop/books.csv' DELIMITER ',' CSV;
- Check to make sure it worked:
SELECT * FROM books;
Once you have your tables set up, you can use a GUI like pgAdmin to see your tables and run your queries.
Once I'm done with the course, I'll create a GitHub repo with the .sql files that do all these steps automatically and post the link on the first video of the course. With that said, knowing how to convert an HTML table to a SQL table is a good skill to have, since there is lots of tabular data on the internet.
Alex Pearson
1,820 Pointshttp://www.seanlahman.com/baseball-archive/statistics/
- I used filezilla to transfer the download into /root on my linux server
- unzip lahman2016-sql.zip
- Use myql dump to drop the data into your database
David Wright
4,437 PointsDavid Wright
4,437 PointsI would also love to find out if these files are available. Thanks.