SQLAlchemy Multiple-Choice Questions (MCQs)

SQLAlchemy is an open-source SQL toolkit and object-relational mapper for the Python programming language released under the MIT License.

SQLAlchemy MCQs: This section contains multiple-choice questions and answers on the various topics of SQLAlchemy. Practice these MCQs to test and enhance your skills on SQLAlchemy.

List of SQLAlchemy MCQs

1. What do you mean by ORM?

  1. Oriented relational mapping
  2. Object-relational mapping
  3. Object relation method

Answer: B) Object-relational mapping

Explanation:

ORM stands for object-relational mapping.

Discuss this Question


2. Why do we use ORM?

  1. It acts as a bridge between object-oriented programs and relational databases.
  2. It acts as a bridge between object-oriented programs and non-relational databases.
  3. It acts as a bridge between relational databases and non-relational databases.

Answer: A) It acts as a bridge between object-oriented programs and relational databases.

Explanation:

It acts as a bridge between object-oriented programs and relational databases.

Discuss this Question


3. Which of the following tools can be used as alternatives to SQLAlchemy?

  1. Django
  2. Hibernate
  3. Pandas
  4. MySQL
  5. All of the above

Answer: E) All of the above

Explanation:

Some alternatives of SQLAlchemy are as follows: Django, Hibernate, Pandas, MySQL, Sequelize, etc.

Discuss this Question


4. Which of the following is the creator of SQLAlchemy?

  1. Raymond Boyce
  2. Donald Chamberlin.
  3. Michael Bayer

Answer: C) Michael Bayer

Explanation:

Michael Bayer created SQLAlchemy.

Discuss this Question


5. Which of the following commands will you use to install SQLAlchemy using PIP?

  1. Pip install alchemy
  2. Pip install SQL alchemy
  3. Pip install sqlalchemy
  4. Pip install SQL
  5. Pip install alchemy

Answer: C) Pip install sqlalchemy

Explanation:

Pip install sqlalchemy, is the command which we will use for installing SQLAlchemy using the python package manager.

Discuss this Question


6. How many distinct components does SQLAlchemy have?

  1. 4
  2. 5
  3. 3
  4. 2

Answer: D) 2

Explanation:

SQLAlchemy has two distinct components mainly known as core and ORM.

Discuss this Question


7. Which SQLAlchemy component consists of the SQL rendering engine, DBAPI integration, transaction integration, and schema description services?

  1. SQLAlchemy Core
  2. SQLAlchemy ORM

Answer: A) SQLAlchemy Core

Explanation:

SQLAlchemy Core components consist of the SQL rendering engine, DBAPI integration, transaction integration, and schema description services.

Discuss this Question


8. Which SQLAlchemy component provides a domain-centric mode of usage?

  1. SQLAlchemy Core
  2. SQLAlchemy ORM

Answer: B) SQLAlchemy ORM

Explanation:

SQLAlchemy ORM component provides a domain-centric mode of usage.

Discuss this Question


9. Which SQLAlchemy component provides schema-centric usage?

  1. SQLAlchemy Core
  2. SQLAlchemy ORM

Answer: A) SQLAlchemy Core

Explanation:

SQLAlchemy Core component provides schema-centric usage.

Discuss this Question


10. Which class connects a pool and a dialect in SQLAlchemy?

  1. Core class
  2. ORM class
  3. Engine class
  4. Object class

Answer: C) Engine class

Explanation:

Engine class connects a pool and a dialect in SQLAlchemy.

Discuss this Question


11. How do you instantiate the object of the engine class?

  1. Using object_engine()
  2. Using create_object()
  3. Using engine_object()
  4. Using create_engine()

Answer: D) Using create_engine()

Explanation:

Using the create_engine() function we instantiate the object of the engine class.

Discuss this Question


12. Which of the following is a shortcut to established SQLAlchemy logging?

  1. Flag=1
  2. Echo flag
  3. Flag=0

Answer: B) Echo flag

Explanation:

Echo flag is a shortcut to established SQLAlchemy logging.

Discuss this Question


13. What does the create_engine() function return?

  1. Object
  2. Value
  3. Engine object
  4. Engine object value

Answer: C) Engine object

Explanation:

Create_engine() function returns the engine object.

Discuss this Question


14. Which of the following returns the connection object?

  1. Connect()
  2. Execute()
  3. Dispose()
  4. Transaction()

Answer: A) Connect()

Explanation:

Connect() method returns us the connection object.

Discuss this Question


15. Which of the following methods will you use if you want to cast out the connection pool?

  1. Driver()
  2. Execute()
  3. Dispose()
  4. Transaction()

Answer: C) Dispose()

Explanation:

Dispose() method is used when you want to cast out/ dispose of the connection pool.

Discuss this Question


16. What is metadata?

  1. Metadata contains the rows information only.
  2. Metadata contains the column information only.
  3. Metadata contains the definition of the table but not their associated objects.
  4. Metadata contains the definitions of tables including the associated objects like views etc.

Answer: D) Metadata contains the definitions of tables including the associated objects like views etc.

Explanation:

Metadata holds the definitions of tables including the associated objects like views etc.

Discuss this Question


17. All defined table objects are created using the engine object and stored in metadata via the ____ function.

  1. Create_engine()
  2. Create_table()
  3. Create_all()
  4. Create_db()

Answer: C) Create_all()

Explanation:

All defined table objects are created using the engine object and stored in metadata via the Create_all() function.

Discuss this Question


18. The object returned by the. The Execute() method is known as ____-?

  1. Result Proxy
  2. Result
  3. Result_object

Answer: A) Result Proxy

Explanation:

The object returned by the. The Execute() method is known as the resultproxy.

Discuss this Question


19. How many records does the fetchone() function return?

  1. All the records
  2. Only single record
  3. All the columns
  4. All the rows

Answer: B) Only single record

Explanation:

Fetchone() function returns us the single record.

Discuss this Question


20. How do you combine multiple conditions in the WHERE clause in SQLAlchemy?

  1. And()
  2. And_()
  3. Or()
  4. Or_()

Answer: B) And_()

Explanation:

And_() is used to combine multiple conditions in the WHERE clause in SQLAlchemy.

Discuss this Question


21. If you want to turn a selectable object into an alias, which function will you use?

  1. alias()
  2. Same()
  3. From clause. Alias()
  4. .alias()

Answer: C) From clause. Alias()

Explanation:

From clause. Alias() function turns a selectable object into an alias.

Discuss this Question


22. Which of the following you will use, if you want to use an operator in SQLAlchemy?

  1. Or
  2. Or_()
  3. Or()
  4. _or()

Answer: B) Or_()

Explanation:

In SQLAlchemy or operator is written as or_().

Discuss this Question


23. Which of the following is the correct syntax to sort the names in ascending order?

  1. pool = select([students]).order_by.asc(students.c.name)
  2. pool = select([students]).asc(students.c.name)
  3. pool = select([students]).where(asc(students.c.name))
  4. pool = select([students]).order_by(asc(students.c.name))

Answer: D) pool = select([students]).order_by(asc(students.c.name))

Explanation:

The correct syntax to sort the names in ascending order is:

pool = select([students]).order_by(asc(students.c.name))

Discuss this Question


24. Which of the following functions is used when you have to check if the value of a certain column falls between a range?

  1. Between()
  2. Range()
  3. Asc()
  4. Check()

Answer: A) Between()

Explanation:

Between() function is used when you have to check if the value of a certain column falls between a range.

Discuss this Question


25. Which of the following functions returns the number of rows selected from a table?

  1. total()
  2. Range()
  3. count()
  4. fetchone()

Answer: C) count()

Explanation:

Count() function returns the number of rows selected from a table.

Discuss this Question


26. In SQLAlchemy, if you want to use the max function, what syntax would you write?

  1. Max()
  2. Max_()
  3. Func.max()
  4. Max

Answer: C) Func.max()

Explanation:

Func.max() is the correct syntax to use max in SQLAlchemy.

Discuss this Question


27. In SQLAlchemy, if you want to use the min function, which API will you import?

  1. Import min
  2. Import min function
  3. Import minimum
  4. Import func

Answer: D) Import func

Explanation:

The func keyword in SQLAlchemy API is used to generate generic functions.

Discuss this Question


28. Which of the following functions is used to eradicate duplicates from the result set?

  1. Remove()
  2. Remove_dup()
  3. Union()
  4. Intersect()

Answer: C) Union()

Explanation:

Union() function is used to eradicate duplicates from the result set.

Discuss this Question


29. ____ function or operators are used when merging two SELECT statements and returning rows that were not returned by the second SELECT statement?

  1. Remove()
  2. Except()
  3. Union()
  4. Intersect()

Answer: B) Except()

Explanation:

Except() function or operator is used when merging two SELECT statements and returning rows that were not returned by the second SELECT statement.

Discuss this Question


30. Which of the following functions shows mutual rows from both the SELECT statements?

  1. Remove()
  2. Except()
  3. Union()
  4. Intersect()

Answer: D) Intersect()

Explanation:

Intersect() function shows mutual rows from both the SELECT statements.

Discuss this Question


31. How many arguments does the create_engine() function take?

  1. 2
  2. 3
  3. 4
  4. 1

Answer: A) 2

Explanation:

Create engine takes two arguments, the name of the database and the echo partner.

Discuss this Question


32. Declarative swaps all the Column objects with special Python accessors known as ____?

  1. Accessors
  2. Descriptors
  3. Descriptions

Answer: B) Descriptors

Explanation:

Declarative replaces all the Column objects with special Python accessors known as descriptors.

Discuss this Question


33. Which of the following functions flushes all items and any transaction in progress?

  1. Commit()
  2. Flush()
  3. Expire()
  4. Rollback()

Answer: A) Commit()

Explanation:

Commit() function flushes all items and any transaction in the progress.

Discuss this Question


34. Which of the following functions closes the session using connection invalidation?

  1. Flush()
  2. Expire()
  3. Rollback()
  4. Invalidate()

Answer: D) Invalidate()

Explanation:

Invalidate() function closes the session using connection invalidation.

Discuss this Question


35. To add multiple records, which of the following functions will you use?

  1. add()
  2. add_all()
  3. commit()
  4. Invalidate()

Answer: B) add_all()

Explanation:

add_all() function is used to add multiple records.

Discuss this Question


36. To add one or more columns, which of the following functions will you use?

  1. columns()
  2. columns_add()
  3. add_columns()

Answer: C) add_columns()

Explanation:

add_columns() function is used to add one or more columns.

Discuss this Question


37. In which of the following methods, the instance returned will provide direct access to the identity map of the session that owns the primary key identifier?

  1. join()
  2. one()
  3. add()
  4. Get()

Answer: D) Get()

Explanation:

In get() function the instance returned will provide direct access to the identity map of the session that owns the primary key identifier.

Discuss this Question


38. If you want to validate whether the column value belongs to a collection of items in a list then which of the following functions you will use?

  1. In()
  2. Like()
  3. Set_in()
  4. In_()

Answer: A) In()

Explanation:

In_() method validates whether the column value belongs to a collection of items in a list.

Discuss this Question


39. Is there any difference between the first() method and one() method?

  1. Yes
  2. No

Answer: A) YES

Explanation:

First() method typically applies a limit of one and returns the foremost result whereas one() method completely fetches all rows.

Discuss this Question


40. Which of the following methods returns the first element of the first result?

  1. One()
  2. First()
  3. Scalar()
  4. Fetch()

Answer: C) Scalar()

Explanation:

Scalar() method returns the first element of the first result.

Discuss this Question


41. Is the scalar() method and one() method both perform the same functionality?

  1. Yes
  2. No

Answer: B) NO

Explanation:

No, both are different. Scalar() method returns the first element of the first result, whereas the one() method completely fetches all rows.

Discuss this Question


42. In which of the following function text is composed into a statement that is passed to the database with the majority of its original form?

  1. Filter()
  2. Text()
  3. Query()
  4. Text_all()

Answer: B) Text()

Explanation:

In the Text() method, the text is composed into a statement that is passed to the database with the majority of its original form.

Discuss this Question


43. How many relationship patterns does SQLAlchemy provide?

  1. 5
  2. 6
  3. 4
  4. 3

Answer: C) 4

Explanation:

SQLAlchemy provides four types of relationship patterns: one-to-many, many-to-one, one-to-one, and many to many.

Discuss this Question


44. Which kind of relationship refers to a parent with the help of a foreign key on the child table?

  1. One to many
  2. Many to one
  3. One to one
  4. Many to many.

Answer: A) One to many

Explanation:

One-to-many relationships refers to parents with the help of a foreign key on the child table.

Discuss this Question


45. Which kind of relationship places a foreign key in the parent table referencing the child?

  1. One to many
  2. Many to one
  3. One to one
  4. Many to many.

Answer: B) Many to one

Explanation:

Many-to-one relationship places a foreign key in the parent table referencing the child.

Discuss this Question


46. To achieve the left outer join, which of the following functions is used?

  1. Join()
  2. Join_left()
  3. Outerjoin()
  4. Outer_join()

Answer: C) Outerjoin()

Explanation:

Outerjoin() is used to achieve left outer join.

Discuss this Question


47. If you want to apply a JOIN to a SELECT statement so that the related rows are loaded in the same result set, which form of relationship loading will you use?

  1. Lazyload()
  2. Joinedload()
  3. Subqueryload()

Answer: B) Joinedload()

Explanation:

Joinedload() is used when you want to apply a JOIN to a SELECT statement so that the related rows are loaded in the same result set.

Discuss this Question


48. ____ is the system SQLAlchemy uses to interconnect with various types of DBAPI implementations and databases.

  1. Dialect
  2. core
  3. ORM

Answer: A) Dialect

Explanation:

Dialect is the system that SQLAlchemy uses to interconnect with various types of DBAPI implementations and databases.

Discuss this Question


49. Which of the following dialects are included in the SQLAlchemy?

  1. PostgreSQL
  2. MySQL and MariaDB
  3. SQLite
  4. All of the above

Answer: D) All of the above

Explanation:

Following dialects are included in SQLAlchemy: Firebird, Microsoft SQL Server, MySQL, Oracle, PostgreSQL.

Discuss this Question


50. Which of the following is the default DBAPI that the MYSQL dialect uses?

  1. MySQL
  2. mysql-python
  3. Basic_MySQL
  4. Mysql_PY

Answer: B) mysql-python

Explanation:

mysql-python is the default DBAPI that MYSQL dialect uses.

Discuss this Question


51. Which language does SQLAlchemy use?

  1. Python
  2. C++
  3. C
  4. JAVA

Answer: A) Python

Explanation:

SQLAlchemy is based on python language.

Discuss this Question


52. When did SQLAlchemy come into existence?

  1. 14 Jan 2006
  2. 14 Feb 2006
  3. 14 Feb 2008
  4. 14 Feb 2010

Answer: B) 14 Feb 2006

Explanation:

SQLAlchemy was released on 14 Feb 2006.

Discuss this Question





Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.