Junior — Middle
Have you ever created and executed SQL queries during your work?
sobes.tech AI
Answer from AI
Yes, during work it was often necessary to create and execute SQL queries to interact with the database. For example, using Python and the sqlite3 library, you can perform a data selection query:
import sqlite3
conn = sqlite3.connect('example.db')
cursor = conn.cursor()
cursor.execute("SELECT * FROM users WHERE age > ?", (30,))
rows = cursor.fetchall()
for row in rows:
print(row)
conn.close()
This approach allows for dynamically forming queries and retrieving the necessary data from the database.