1.__7.3 (Contacts
books.sql code:
import panda as pd
import sqlite3
connection = sqlite3.connect('books.db')
pd.options.display.max_columns = 10
pd.read_sql("SELECT * FROM authors",connection)
df = pd.read_sql( "SELECT * FROM authors",connection)
DROP TABLE IF EXISTS author_ISBN;
DROP TABLE IF EXISTS titles;
DROP TABLE IF EXISTS authors;
CREATE TABLE authors (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
first TEXT NOT NULL,
last TEXT NOT NULL
);
CREATE TABLE titles (
isbn TEXT NOT NULL,
title TEXT NOT NULL,
edition INTEGER NOT NULL,
copyright TEXT NOT NULL,
PRIMARY KEY (isbn)
);
CREATE TABLE author_ISBN (
id INTEGER NOT NULL,
isbn TEXT NOT NULL,
PRIMARY KEY (id, isbn),
FOREIGN KEY (id) REFERENCES authors(id) ON DELETE CASCADE,
FOREIGN KEY (isbn) REFERENCES titles (isbn) ON DELETE CASCADE
);
PRAGMA foreign_keys = ON;
INSERT INTO authors (first, last)
VALUES
('Paul','Deitel'),
('Harvey','Deitel'),
('Abbey','Deitel'),
('Dan','Quirk'),
('Alexander', 'Wald');
INSERT INTO titles (isbn,title,edition,copyright)
VALUES
('0135404673','Intro to Python for CS and DS',1,'2020'),
('0132151006','Internet & WWW How to Program',5,'2012'),
('0134743350','Java How to Program',11,'2018'),
('0133976890','C How to Program',8,'2016'),
('0133406954','Visual Basic 2012 How to Program',6,'2014'),
('0134601548','Visual C# How to Program',6,'2017'),
('0136151574','Visual C++ How to Program',2,'2008'),
('0134448235','C++ How to Program',10,'2017'),
('0134444302','Android How to Program',3,'2017'),
('0134289366','Android 6 for Programmers',3,'2016');
INSERT INTO author_ISBN (id,isbn)
VALUES
(1,'0134289366'),
(2,'0134289366'),
(5,'0134289366'),
(1,'0135404673'),
(2,'0135404673'),
(1,'0132151006'),
(2,'0132151006'),
(3,'0132151006'),
(1,'0134743350'),
(2,'0134743350'),
(1,'0133976890'),
(2,'0133976890'),
(1,'0133406954'),
(2,'0133406954'),
(3,'0133406954'),
(1,'0134601548'),
(2,'0134601548'),
(1,'0136151574'),
(2,'0136151574'),
(4,'0136151574'),
(1,'0134448235'),
(2,'0134448235'),
(1,'0134444302'),
(2,'0134444302'.
Trending nowThis is a popular solution!
Step by stepSolved in 7 steps with 4 images
- 1. Load packages to work with Database Link.2. Open connection with SQL database named "publisher".3. Find the directory on your computer where the \ is locatedpublisher database In mathematica wolframarrow_forwardimport sqlite3 from sqlite3 import Error # Creates connection to sqlite in-memory database def create_connection(): """ Create a connection to in-memory database :return: Connection object """ try: conn = sqlite3.connect(":memory:") return conn except Error as e: print(e) # YOUR CODE HERE # Use sqlite3.connect(":memory:") to create connection object return conn # query to create the table table_sql = """ CREATE TABLE Horses ( id integer PRIMARY KEY NOT NULL, name text, breed text, height real, birthday text ); """ # query to insert data into the table ins_sql = """INSERT INTO Horses VALUES(1,'Babe','Quarter Horse',15.3,'2015-02-10'); """ # query to fetch all data from the table fetch_sql = """SELECT * FROM Horses;""" # creating db connection conn = create_connection() # fetching a cursor from the connection c = conn.cursor() # executing statement to create table c.execute(table_sql) # executing statement to…arrow_forwardNeed some help understanding this Python program that creates a new database named DSUCollege.db and calls 4 functions. The function named create_table will create a table in the DSUCollege.db database called students that has five fields: student_id, first_name, last_name, major, and gpa. The first_name, last_name, and major columns should be TEXT data types, the student_id column should be an INTEGER datatype and gpa should be a REAL datatype (link to SQLite Data typesLinks to an external site.). Before creating the table, add code to drop the table. After the table has been created, display a message that the table has been created successfully. The function named populate_table populates the students table with the following values: student_id first_name last_name major gpa 1111 Dave Grohl Music 4.0 2222 Belinda Carlisle Accounting 3.5 3333 Joe Elliot Computer Science 2.8 4444 Angus Young Accounting 2.1 5555 Susanna Hoffs Music 3.1 6666 Debbie Harry Computer…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education