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

Python Using Databases in Python Meet Peewee Modeling

how to read the database from computer

I'm trying to see the tables from my database like kenneth done in the video.

>>>sqlite3 student.db

but when i tried it in the python idle it didn't work.please tell me how i can read my database from my windows computer

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

sqlite3 command is run in a command shell or system console window. It appears you are trying to run it in the Python shell. Exit the Python shell before trying the command.

To run sqlite3 on windows, it will need to be installed on your machine first. It can be downloaded here

Please tell me how to install sqlite3 on the windows.i downloaded it from your download link but that is not the installation file it is run directly when i run it.so please tell me how can i install it in my pc.

Thnks chris my problem is now solved

Matthew Shipman
Matthew Shipman
11,369 Points

I'm also struggling with using command prompt to view the database contents. This website doesn't appear to have a .exe file available for windows.

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

You have to be out of the Python shell. exit() will exit the shell.

Just an update to downloading sqlite3 for windows: skip step 1 and 2 in the provided link https://www.tutorialspoint.com/sqlite/sqlite_installation.htm
Instead, go to https://www.sqlite.org/download.html (as described in step 1) but just download the 3rd file under the "Precompiled Binaries for Windows" heading. This file has a description of "A bundle of command-line tools for managing...." That's the only file I needed. Then I continued with steps 3 and 4 and everything works!

What I've learned about Path If you read step 4 and don't have a clue where to find this, go to your Windows Setting and search for "environ". That will hopefully point you in the right direction. On my computer, it's under System Properties (wherever that is!) > Environment Variables > [highlight Path variable] > Edit > New. This is handy to know, not just for setting up sqlite3. Path also affects how you can import things in python, so I've learned. For example, if you run this in python:

import sys
sys.path.append(r'something_here')

you can add on to your python-related path (at least temporarily... when I do it, at least, it's temporarily... seems to last till the session ends) to access python modules. You see, the reason why you can import the Standard Library modules (sys, csv, re, random, etc.) with just "import name" is because the Standard Library resides in a directory that's in python's path.... python knows where it is. Else your import statement would be "from something.something.something import name" to tell Python where the module is you want to import. If you want to know more about how Windows/etc uses a path environment variable, you may want to google it as I'm no expert... BUT I've found that knowing the above is really handy : )