ENCOR Exam QuestionsBrowse all questions from this exam

ENCOR Exam - Question 688


Refer to the exhibit.

What does this Python script do?

Show Answer
Correct Answer: B

This Python script reads the username for a specific IP address from a light (SQLite) database. It connects to the SQLite database, creates a cursor object to execute SQL commands, constructs and executes a query to select the user from the monitor_branch table where the loopback IP matches a specified IP address, fetches the result, and processes the retrieved username. The script only reads the data and does not perform any write operations on the database.

Discussion

16 comments
Sign in to comment
jackr76
Mar 24, 2023

WTF is this a Cisco or SQL exam

dragonwise
Apr 6, 2023

They think we're not worthy of the certificate if we do answer this question

mgiuseppe86
Sep 13, 2023

Thats my biggest gripe with the new CCNP. It's all BS Cloud/WiFi/Automation. WHAT HAPPENED TO REAL LAYER 1 2 3 NETWORKING

ando2023
Jun 19, 2023

I've recertified my ccnp since 2013 a few times, but now Cisco all of a sudden is going off in such a different direction. Switching and routing is now such a small part of the overall requirements.

Dre876
Sep 7, 2023

tell me about it!

mgiuseppe86
Sep 13, 2023

Thats my biggest gripe with the new CCNP. It's all BS Cloud/WiFi/Automation. WHAT HAPPENED TO REAL LAYER 1 2 3 NETWORKING

Badger_27
Mar 9, 2023

WTF are they serious?

zogerixty
Mar 16, 2023

Can't understand?

Badger_27
Mar 20, 2023

No- how are you supposed to if you don't regularly use Python and the SQLite module?

Badger_27
Mar 20, 2023

No- how are you supposed to if you don't regularly use Python and the SQLite module?

Sammy3637
Feb 20, 2023

no clue ... didn't see this coming , not in OCG

slacker_at_work
Feb 29, 2024

Here's a breakdown of what each part does: -1 Importing sqlite3: This line imports the SQLite3 module in Python, allowing the script to interact with SQLite databases. -2 Connecting to the database: The script connects to a SQLite3 database located at /home/sdwan-lab/user.sqlite3. This is done using the connect() method of the sqlite3 module, which returns a connection object (a in this case). -3 Creating a cursor object: Cursors are used to execute SQL queries on the connected database. The cursor() method creates a cursor object (b in this case) associated with the connection

slacker_at_work
Feb 29, 2024

- 4 SQL Query: The variable c contains an SQL query. It appears to be selecting the user column from a table named monitor_branch where the loopbackip matches a specific pattern. However, there seems to be a syntax error in the query. The string concatenation is not done properly. - 5 Executing the query: The execute() method of the cursor b executes the SQL query stored in the variable c. - 6 Fetching the results: The fetchall() method retrieves all the rows returned by the query execution and stores them in the variable e. - 7 Processing the result: The script then appears to be manipulating the fetched result. It converts the first element of the result (e[0]) to a string, removes any occurrences of ( and ,) from the string, and assigns the modified string back to the variable usr.

Nation_2024
Jul 3, 2024

Thankyou

HungarianDish_111Option: B
Mar 24, 2023

B seems to be correct, because data only needs to be read from the DB, and not altered. https://www.google.com/amp/s/www.geeksforgeeks.org/how-to-list-tables-using-sqlite3-in-python/amp/

djedeenOption: B
Aug 24, 2023

B: good link here for similar queries from sqlite3 DB. https://pyneng.readthedocs.io/en/latest/book/25_db/sqlite3_fetch.html

mgiuseppe86
Sep 16, 2023

doesn the usr.replace string write the username back to the DB once it selects it from the table monitor_Branch?

RickAO76Option: C
Apr 22, 2024

I'm 50/50 with it being B or C. The two lines for .... usr = usr.replace() ...functions, are for writing. - I honestly just hope I don't see this question :-/

RickAO76
Apr 22, 2024

Re-visiting - I'm leaning to B now for read. The replace looks like it's only replacing the special characters.

[Removed]Option: B
Jun 7, 2024

B is correct The keyword is: c = "select user from monitor branch where loopbackip='" + str(ip[i]) + "'"

[Removed]
Jun 21, 2024

...........................

CiscoTerminator
Aug 18, 2024

I wonder what is being asked in devops then, if these are encor questions?

AbdullahMohammad251Option: B
Oct 1, 2024

Connect to the SQLite database (user.sqlite) Execute the SQL query (find the username for a given IP address: the IP address stored in the list item with index 'i') Fetch the entire result set and parse it into a Python list (list 'e') Modify the result list - in our example, curly brackets were replaced with double quotes

[Removed]
May 25, 2024

i'm going with B, no idea why :D

Steve122Option: B
Jul 11, 2024

Definitely 'B'. After getting the username from e[0] it removes the ( and ) chars from string. (nothing written back to DB)

johndoen
Oct 1, 2024

I this sql exam or cisco one , I dont see get it just like I wasn't able to roam my globe sim before knowing https://theglobesimregistration.ph

chmacnpOption: B
Jan 29, 2025

nice one slacker_at_work !