-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfastAPI-SQL.json
More file actions
179 lines (179 loc) · 6.85 KB
/
Copy pathfastAPI-SQL.json
File metadata and controls
179 lines (179 loc) · 6.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
{
"mcqs": {
"SQLAlchemy and FastAPI Integration": {
"Core Concepts and CRUD Operations": [
{
"title": "SQLAlchemy and FastAPI Integration - Quiz",
"description": "Test your knowledge of SQLAlchemy, FastAPI, and their integration for database operations.",
"questions": [
{
"question": "What is SQLAlchemy primarily used for?",
"options": [
"Creating user interfaces.",
"Handling HTTP requests in Python.",
"Providing an ORM for interacting with databases.",
"Managing server infrastructure."
],
"answer": "Providing an ORM for interacting with databases.",
"difficulty": "Beginner"
},
{
"question": "What does ORM stand for in the context of SQLAlchemy?",
"options": [
"Object Relational Mapping",
"Object Rendering Model",
"Operational Resource Management",
"Object Request Manager"
],
"answer": "Object Relational Mapping",
"difficulty": "Beginner"
},
{
"question": "Which of the following is NOT a benefit of using an ORM like SQLAlchemy?",
"options": [
"Increased code readability.",
"Database abstraction.",
"Automatic SQL injection prevention.",
"Direct SQL query execution."
],
"answer": "Direct SQL query execution.",
"difficulty": "Intermediate"
},
{
"question": "How does SQLAlchemy connect to a database?",
"options": [
"Through a connection string.",
"By directly embedding the database file.",
"Via a web browser interface.",
"Using a proprietary API."
],
"answer": "Through a connection string.",
"difficulty": "Beginner"
},
{
"question": "In SQLAlchemy, what is a `Model`?",
"options": [
"A representation of a database table as a Python class.",
"A function for handling HTTP requests.",
"A configuration file for the database.",
"A tool for visualizing database schemas."
],
"answer": "A representation of a database table as a Python class.",
"difficulty": "Beginner"
},
{
"question": "What is the purpose of `Base` in SQLAlchemy?",
"options": [
"It's the base class for all database models.",
"It's a function for creating database connections.",
"It's a decorator for defining API endpoints.",
"It's a tool for managing database migrations."
],
"answer": "It's the base class for all database models.",
"difficulty": "Intermediate"
},
{
"question": "Which of the following is a valid CRUD operation?",
"options": [
"Compile",
"Refactor",
"Update",
"Deploy"
],
"answer": "Update",
"difficulty": "Beginner"
},
{
"question": "In FastAPI, how do you typically access the database session?",
"options": [
"Through global variables.",
"By directly importing the database connection.",
"Using dependency injection.",
"By creating a new session for each request."
],
"answer": "Using dependency injection.",
"difficulty": "Intermediate"
},
{
"question": "Which HTTP method is typically used for creating a new resource in a RESTful API?",
"options": [
"GET",
"PUT",
"POST",
"DELETE"
],
"answer": "POST",
"difficulty": "Beginner"
},
{
"question": "Which HTTP method is typically used for retrieving a resource in a RESTful API?",
"options": [
"POST",
"PUT",
"GET",
"DELETE"
],
"answer": "GET",
"difficulty": "Beginner"
},
{
"question": "Which HTTP method is typically used for updating an existing resource in a RESTful API?",
"options": [
"POST",
"PATCH",
"GET",
"DELETE"
],
"answer": "PATCH",
"difficulty": "Intermediate"
},
{
"question": "Which HTTP method is typically used for deleting a resource in a RESTful API?",
"options": [
"POST",
"PUT",
"GET",
"DELETE"
],
"answer": "DELETE",
"difficulty": "Beginner"
},
{
"question": "What is the purpose of `db.add(instance)` in SQLAlchemy?",
"options": [
"To delete an instance from the database.",
"To add a new instance to the database session.",
"To update an existing instance in the database.",
"To query the database for an instance."
],
"answer": "To add a new instance to the database session.",
"difficulty": "Beginner"
},
{
"question": "What does `db.commit()` do in SQLAlchemy?",
"options": [
"It rolls back the current transaction.",
"It saves the changes made in the session to the database.",
"It closes the database connection.",
"It starts a new transaction."
],
"answer": "It saves the changes made in the session to the database.",
"difficulty": "Beginner"
},
{
"question": "What is the purpose of using `async def` when defining FastAPI routes that interact with a database?",
"options": [
"To make the route run faster.",
"To enable asynchronous database operations, preventing blocking.",
"To automatically generate API documentation.",
"To simplify error handling."
],
"answer": "To enable asynchronous database operations, preventing blocking.",
"difficulty": "Advanced"
}
]
}
]
}
}
}