Junior — Middle
Do you have experience working with relational databases?
sobes.tech AI
Answer from AI
Yes, I have experience working with relational databases. Specifically, I have used DBMS such as MySQL, PostgreSQL, and SQLite.
In Python, libraries commonly used for interacting with relational databases include:
sqlite3— a built-in library for working with SQLite.psycopg2— for PostgreSQL.mysql-connector-pythonorPyMySQL— for MySQL.- ORM libraries, such as SQLAlchemy or Django ORM, which simplify database work by allowing you to write queries in Python instead of SQL.
An example of a simple query using sqlite3:
import sqlite3
conn = sqlite3.connect('example.db')
cursor = conn.cursor()
# Creating a table
cursor.execute('''CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)''')
# Inserting data
cursor.execute('INSERT INTO users (name) VALUES (?)', ('Ivan',))
conn.commit()
# Reading data
cursor.execute('SELECT * FROM users')
rows = cursor.fetchall()
for row in rows:
print(row)
conn.close()
This experience allows me to work effectively with relational databases in various projects.