Mixed-Up Code Questions

Import the sqlite3 package, create a conection to the file music.db, create the cursor, drop the Tracks table if it exists, next create a table Tracks with two columns (title which is text and plays which is an integer), commit the changes, and finally close the connection.

Import the sqlite3 package, create a conection to the file music.db, create the cursor, drop the Tracks table if it exists, next create a table Tracks with two columns (title which is text and plays which is an integer), commit the changes, and finally close the connection.

Create code to connect to the database file ‘chinook.db’ which contains a table albums with three columns AlbumID, Title` and ArtistID. Insert 2 tracks into the table. The first track has an albumID of 348, title “Thunderstruck”, and ArtistID of 300. The second track has an albumID 349, title “My Way” with 301 ArtistID.

Write code to connect to the database file ‘chinook.db’ which contains a table albums with three columns AlbumID, Title` and ArtistID. Insert 2 tracks into the table. The first track has an albumID of 348, title “Thunderstruck”, and ArtistID of 300. The second track has an albumID 349, title “My Way” with 301 ArtistID.

Create code to connect to a database file ‘bikeshare.db’. Print the number of rows in the table bikeshare_stations. Close the cursor.

Write code to connect to a database file ‘bikeshare.db’. Then selects all of the rows in the table bikeshare_stations. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Create a connection to the database ‘pets.sqlite’ and add a table Dogs with two columns, name and breed. Insert 2 dogs into the table. The first dog is named Penelope and is a Doberman. The second dog is named Milo and is a Springer Spaniel. Commit the change, then select the name(s) of the dogs of breed Springer Spaniel.

Write code to create a connection to the database ‘pets.sqlite’ and add a table Dogs with two columns, name and breed. Insert 2 dogs into the table. The first dog is named Penelope and is a Doberman. The second dog is named Milo and is a Springer Spaniel. Commit the change, then select the name(s) of the dogs of breed Springer Spaniel.

Create code to connect to a database file ‘bikeshare.db’. Then only selects the rows in the table bikeshare_stations that have a status of closed. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Write code to connect to a database file ‘bikeshare.db’. Then only selects the rows in the table bikeshare_stations` that have a status of closed. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Create a connection to the ‘chinook.db’ database. Select rows LastName and FirstName` in the table customers in alphabetical order by LastName. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Write code to create a connection to the ‘chinook.db’ database. Select rows LastName and FirstName` in the table customers in alphabetical order by LastName. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Create code to connect to a database file ‘chinook.db’. Join tables albums and artists. Then, select the artist Name where ArtistID` is 90. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Write code to connect to a database file ‘chinook.db’. Join tables albums and artists. Then, select the artist Name where ArtistID` is 90. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Create a connection to the ‘chinook.db’ database. Then, join tables ‘albums’ and ‘artists’ on ‘artistId’. Then, set the variables title and artist equal to the title name and artist name in row 185.

Write code to connect to the ‘chinook.db’ database. Then, join tables ‘albums’ and ‘artists’ on ‘artistId’. Then, set the variables title and artist equal to the title name and artist name in row 185.

Create code to connect to a database file ‘chinook.db’. Select the name of all rows of data where the genre Name is ‘Pop’ and MediaTypeID is 1. In order to do this, first join tables tracks and genres. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

Create code to connect to a database file ‘chinook.db’. Select the name of all rows of data where the genre Name is ‘Pop’ and MediaTypeID is 1. In order to do this, first join tables tracks and genres. Set the variable count_rows to the total number of rows returned from the query, before closing the cursor.

You have attempted of activities on this page