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 trial

Databases

yalın küçük
yalın küçük
4,810 Points

Downloading database file of the course ( SQL Basic Track ) and study them on my workstation ( Mac ).

Hi,

We can download the php ( folder as a .zip file) files and because I setup a server on my mac I can study via my localhost.

I have started SQL but I could not see any file downloading option on the SQL Playground screen.

How can work with the same project of this SQL course on my localhost?

Thanks

3 Answers

Greg Kaleka
Greg Kaleka
39,021 Points

As far as I know there's no good way to do this... Here's an annoying way to do it that should work:

Prerequisite: you have a SQL GUI program like Sequel Pro (free, and available on the Mac), and you have some basic spreadsheet program (the free online Google Sheets would work).

  1. Write the following statement in the playground query: SELECT * FROM TableName;
  2. Copy and paste the results into a spreadsheet. Make sure you get the headers, all the data, and nothing else.
  3. Paste into a spreadsheet
  4. Save as a CSV file
  5. Create a database in your SQL GUI program (name it the same as in the videos for simplicity)
  6. Import the CSV file into the database
  7. Rinse and repeat for each table in the database (obviously you only need to create the database once)

That's annoying, but I don't think there's another way to do it at the moment. You might consider emailing help@teamtreehouse.com to request that they add the ability to download the database data.

Cheers :beers:

-Greg

yalın küçük
yalın küçük
4,810 Points

Hi,

I downloaded DB Browser for SQLite. Then just a minute ago I created 3 tables and copied and pasted index files directly from the spreadsheet view in the browser.

My question is the code part now. Will I use "Execute SQL" tab ( there is this tab on the software interface) to learn the code now? I thought I was going to use terminal. Confused.

Thanks

Greg Kaleka
Greg Kaleka
39,021 Points

You can do it either way. Your GUI will have a query interface kind of like the workspace. You can also interact with the db from the terminal. You'll want to install the sqlite3 program if you don't already have it. Check in the terminal by running sqlite3 --version. If you get a version number, you're all set.

Here's documentation for the CLI. Basically, you type sqlite3 [database_name] and then you're in a sqlite shell for that database and you can do all the normal stuff like SELECT * FROM TableName.

yalın küçük
yalın küçük
4,810 Points

Yesss. I executed SELECT * FROM books; and code showed the table below. I hope I am not doing wrong.

And something is interesting. There is not any date type when you create a data ( new record ) for your table. Instead the software utilise it as text. That is interesting.

Thanks Greg.

Greg Kaleka
Greg Kaleka
39,021 Points

Cool - sounds like you're doing it right :blush:

Yeah sqlite doesn't have a date type. They only have NULL, INTEGER, REAL, TEXT, and BLOB.

Per the documentation:

SQLite does not have a storage class set aside for storing dates and/or times. Instead, the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT, REAL, or INTEGER values:

TEXT as ISO8601 strings ("YYYY-MM-DD HH:MM:SS.SSS").

REAL as Julian day numbers, the number of days since noon in Greenwich on November 24, 4714 B.C. according to the proleptic Gregorian calendar.

INTEGER as Unix Time, the number of seconds since 1970-01-01 00:00:00 UTC.

Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.

Text and Integer are the most commonly used.