WorksheetsSQL Python Connectivity #1
Total questions: 12
Worksheet time: 6mins
Name the method which is used for displaying only one resultset.
fetchmany( )
fetch(1)
fetchall( )
fetchone( )
Identify the Python statement that creates an SQL table out of the following options:
mycursor.execute('CREATE TABLE customers (name VARCHAR(25), 'address' VARCHAR(55))')
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55))")
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address VARCHAR(55));")
mycursor.execute("CREATE TABLE customers (name VARCHAR(25), address (VARCHAR55))")
Assuming mycur to be a cursor object, which Python function is required to ensure that the inserted record has been added to the mentioned table?
To close a connection (CON) we must use:
CON.close( )
con.close( )
CON.end( )
close(CON)
Which command is used for counting the number of rows in a database?
countrow
rowcount
count
row_count
To retreive all the rows from the result set, which method is used?
fetchmany
fetch(1)
fetchall( )
fetchone( )
What is the specific purpose of a cursor with respect to SQL and Python connectivity?
It is used to execute SQL statements
It is used to connect SQL table with Python code
It enables the Python programmer to traverse through the records of an associated SQL table
It is used to open an existing database
Which of the following needs to be used to replace the values provided by the user through Python Code and transfer them into the SQL tables?
{s}
(s)
[s]
%s
Consider a case in which the total number of records in an SQL table is 20, and currently the record point is at the beginning of the 7th record. How many records will be fetched from the table if fetchall( ) is used?
13
14
20
7
Consider a case in which the total number of records in an SQL table is 20, and currently the record point is at the beginning of the 7th record. How many records will be fetched from the table if fetchmany(5) is used?
11
7
5
6
Consider the following Python code:
mycur = mycon.cursor()
x=mycur.execute("select * from student where class='XI' and marks>=75")
Assuming that multiple records have been retreived with the above statement, what is the type of the variable x?
Tuple
List
List of tuples
Tuples of list
Assuming mycur is a cursor object, identify the valid Python statement out of the following statements:
mycur.execute("select * from student where name like "a%"")
mycur.execute("select * from student where name like 'a%'")
execute(mycur,"select * from student where name like 'a%'")
mycur.connect("select * from student where name like 'a%'")
