Professional Documents
Culture Documents
2. What are the basic steps to connect Python with MYSQL using table Members present in the database
‘Society’? (3)
cursor = conn.cursor()
row = cursor.fetchone()
conn.close()
print(row)
3. Write a MySQL-Python connectivity to retrieve data, one record at a time, from city table for employees
try:
cursor = db.cursor()
number_of_rows = cursor.execute(sql)
db.close()
except my.DataError as e:
print("DataError")
1
print(e)
4. Write a MySQL-Python connectivity to retrieve data, one record at a time, from city table for
Ans.
import MySQLdb as my
try:
cursor = db.cursor()
number_of_rows = cursor.execute(sql)
db.close()
except my.DataError as e:
print("DataError")
print(e)
5. Which of the following act as a container to hold all the data returned from the query and from there we
can fetch data at one at a time?
a) Result set
b) Container
c) Cursor
d) Table
6. Which of the symbols are used for passing parametrized query for execution to cursor?
a) %
b) { }
c) $
d) Both a and b