Question

You are working on an address book database with a table called Contacts and fields for...

You are working on an address book database with a table called Contacts and fields for first name, last name, address, and phone number. Describe how you would implement a Python method that prompted the user to add new address entries into the database table. The table should have no duplicates. Include the necessary code and code descriptions. In Python please.

Homework Answers

Answer #1

code:

import mysql.connector

mydb = mysql.connector.connect(
host="localhost",
  username="firstname"

username="lastname",
address="youraddress",

phonenumber="yourphonenumber",
database="mydatabase"
)
mycursor = mydb.cursor()
sql = "INSERT INTO addressbook (name, address) VALUES (%s, %s)"
val = ("John", "Highway 21")
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount, "new address added")

NOTE:  mydb.commit(). It is required to make the changes, otherwise no changes are made to the table.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
PartA: Create the database. Name the database doctorWho. Then create a page that allows Doctor Who’s...
PartA: Create the database. Name the database doctorWho. Then create a page that allows Doctor Who’s assistant to add a new patient record. You will need to give the assistant rights to this database. The assistant’s username is 'helper' and the password is 'feelBetter'. For this to work, you will need to create several pages so be sure to include all of them when submitting your work. Name the main page addPatient.php. PartB: Add at least five records to the...
Q1) Connect to HR database and write the queries to answer the following questions. Provide your...
Q1) Connect to HR database and write the queries to answer the following questions. Provide your queries text and result in a .txt file: a) How many employees you can find in the Employees table b) How many departments are there in this database c) How many employees work for sales department d) What is the average salary of department 50 e) Copy Countries table from HR database into Section 24 using Select Into clause. f) Write a query to...
EX16_AC_CH05_GRADER_ML1_HW - Hotel Chain Project Description: You are the general manager of a large hotel chain....
EX16_AC_CH05_GRADER_ML1_HW - Hotel Chain Project Description: You are the general manager of a large hotel chain. Your establishment provides a variety of guest services ranging from rooms and conferences to weddings. The data entry accuracy of your staff could bear some improvement, so you have decided to move to Microsoft Access and implement several data validation techniques. You also will take advantage of Access's Expression Builder to help analyze data. Steps to Perform: Step   Instructions   Points Possible 1   Start Access....
A. Create a PowerShell script named “restore.ps1” within the “Requirements2” folder. For the first line, create...
A. Create a PowerShell script named “restore.ps1” within the “Requirements2” folder. For the first line, create a comment and include your first and last name along with your student ID. Note: The remainder of this task shall be completed within the same script file, “restore.ps1.” B. Write a single script within the “restore.ps1” file that performs all of the following functions without user interaction: 1. Create an Active Directory organizational unit (OU) named “finance.” 2. Import the financePersonnel.csv file (found...
Use Jvascript to write this code by Visual Studio Code For this lab you must use...
Use Jvascript to write this code by Visual Studio Code For this lab you must use a reasonable faceted search example, each item must have at least three categorical attributes and at least one numeric attribute. Attributes such as ID, name etc do not count as categorical or numeric attributes. (a) Design a web page that includes three input fields one for each categorical attribute and a button whose label is ‘filter’. Also extend your CSV faceted search item file...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with...
PLEASE USING C# TO SOLVE THIS PROBLEM. THANK YOU SO MUCH! a. Create a project with a Program class and write the following two methods (headers provided) as described below: - A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may...
PYTHON : Create a Email Address Parser (* Please do make comments*) Often times, you may be given a list of raw email addresses and be asked to generate meaningful information from such a list. This project involves parsing such a list and generating names and summary information from that list. The script, eparser.py, should: Open the file specified as the first argument to the script (see below) Read the file one line at a time (i.e., for line in...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields,...
in jGRASP INVENTORY CLASS You need to create an Inventory class containing the private data fields, as well as the methods for the Inventory class (object). Be sure your Inventory class defines the private data fields, at least one constructor, accessor and mutator methods, method overloading (to handle the data coming into the Inventory class as either a String and/or int/float), as well as all of the methods (methods to calculate) to manipulate the Inventory class (object). The data fields...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT