- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Computer science, programming - relevant posts, community threads, and courses
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 9: Flask › How to create table structure for froshims.db?
How to create table structure for froshims.db?
byu/DigitalSplendid inlearnSQL
When you run the sqlite3
command without specifying a database file, it opens a new session where you can create and manipulate databases. In your case, you’ve created a table named registrants
, but it’s not associated with any specific database file yet.
To create a table within the froshims.db
file, you need to specify the database file when you invoke sqlite3
. Here’s how you can do it:
$ sqlite3 froshims.db
This command will open the SQLite prompt with froshims.db
as the active database. Then, you can proceed to create your table:
CREATE TABLE registrants (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
sport TEXT NOT NULL
);
After creating the table, you can verify it using the .schema
command as you did before. This ensures that the table is indeed created within the froshims.db
file.
If there are multiple .db
files in your directory, it’s always a good practice to explicitly specify the database file when opening sqlite3
to avoid any confusion about which database you’re working with.