Home »
MCQs
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?
- Oriented relational mapping
- Object-relational mapping
- Object relation method
Answer: B) Object-relational mapping
Explanation:
ORM stands for object-relational mapping.
Discuss this Question
2. Why do we use ORM?
- It acts as a bridge between object-oriented programs and relational databases.
- It acts as a bridge between object-oriented programs and non-relational databases.
- 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?
- Django
- Hibernate
- Pandas
- MySQL
- 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?
- Raymond Boyce
- Donald Chamberlin.
- 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?
- Pip install alchemy
- Pip install SQL alchemy
- Pip install sqlalchemy
- Pip install SQL
- 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?
- 4
- 5
- 3
- 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?
- SQLAlchemy Core
- 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?
- SQLAlchemy Core
- 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?
- SQLAlchemy Core
- 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?
- Core class
- ORM class
- Engine class
- 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?
- Using object_engine()
- Using create_object()
- Using engine_object()
- 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?
- Flag=1
- Echo flag
- 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?
- Object
- Value
- Engine object
- 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?
- Connect()
- Execute()
- Dispose()
- 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?
- Driver()
- Execute()
- Dispose()
- 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?
- Metadata contains the rows information only.
- Metadata contains the column information only.
- Metadata contains the definition of the table but not their associated objects.
- 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.
- Create_engine()
- Create_table()
- Create_all()
- 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 ____-?
- Result Proxy
- Result
- 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?
- All the records
- Only single record
- All the columns
- 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?
- And()
- And_()
- Or()
- 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?
- alias()
- Same()
- From clause. Alias()
- .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?
- Or
- Or_()
- Or()
- _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?
- pool = select([students]).order_by.asc(students.c.name)
- pool = select([students]).asc(students.c.name)
- pool = select([students]).where(asc(students.c.name))
- 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?
- Between()
- Range()
- Asc()
- 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?
- total()
- Range()
- count()
- 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?
- Max()
- Max_()
- Func.max()
- 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?
- Import min
- Import min function
- Import minimum
- 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?
- Remove()
- Remove_dup()
- Union()
- 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?
- Remove()
- Except()
- Union()
- 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?
- Remove()
- Except()
- Union()
- 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?
- 2
- 3
- 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 ____?
- Accessors
- Descriptors
- 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?
- Commit()
- Flush()
- Expire()
- 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?
- Flush()
- Expire()
- Rollback()
- 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?
- add()
- add_all()
- commit()
- 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?
- columns()
- columns_add()
- 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?
- join()
- one()
- add()
- 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?
- In()
- Like()
- Set_in()
- 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?
- Yes
- 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?
- One()
- First()
- Scalar()
- 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?
- Yes
- 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?
- Filter()
- Text()
- Query()
- 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?
- 5
- 6
- 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?
- One to many
- Many to one
- One to one
- 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?
- One to many
- Many to one
- One to one
- 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?
- Join()
- Join_left()
- Outerjoin()
- 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?
- Lazyload()
- Joinedload()
- 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.
- Dialect
- core
- 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?
- PostgreSQL
- MySQL and MariaDB
- SQLite
- 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?
- MySQL
- mysql-python
- Basic_MySQL
- 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?
- Python
- C++
- C
- JAVA
Answer: A) Python
Explanation:
SQLAlchemy is based on python language.
Discuss this Question
52. When did SQLAlchemy come into existence?
- 14 Jan 2006
- 14 Feb 2006
- 14 Feb 2008
- 14 Feb 2010
Answer: B) 14 Feb 2006
Explanation:
SQLAlchemy was released on 14 Feb 2006.
Discuss this Question