Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Using Databases in Python Meet Peewee Modeling

vikas pal
vikas pal
11,252 Points

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,064 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

vikas pal
vikas pal
11,252 Points

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.

vikas pal
vikas pal
11,252 Points

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 : )