Sobes.tech
Junior

Veritabanlarıyla çalışmak için hangi araçları kullandınız?

sobes.tech yapay zeka

AI'dan gelen yanıt

Veritabanlarıyla çalışmak için aşağıdaki araçları kullandım:

  • SQL istemcileri:
    • DBeaver
    • SQL Developer
    • pgAdmin
  • Komut satırı araçları:
    • psql
    • mysql
  • Test otomasyonu için frameworkler ve kütüphaneler:
    • JDBC (Java için)
    • psycopg2 (Python, PostgreSQL için)
    • mysql-connector-python (Python, MySQL için)

Genellikle, SQL istemcilerini manuel veri incelemesi, sorgu yazma ve çalıştırma, ayrıca API veya entegrasyon testleri seviyesinde veri doğrulama otomasyonu için komut satırı araçları ve kütüphaneleri kullandım.

Otomasyonda kullanım örnekleri:

// Tablo içindeki kayıt sayısını kontrol etme
public int getCountOfUsers(String username) {
    String sql = "SELECT COUNT(*) FROM users WHERE username = ?";
    try (Connection conn = DriverManager.getConnection(url, user, password);
         PreparedStatement pstmt = conn.prepareStatement(sql)) {
        pstmt.setString(1, username);
        try (ResultSet rs = pstmt.executeQuery()) {
            if (rs.next()) {
                return rs.getInt(1);
            }
        }
    } catch (SQLException e) {
        e.printStackTrace(); // Hata kaydı
    }
    return 0;
}
# Kayıttaki bir alanın değerini kontrol etme
def get_user_status(user_id):
    conn = None
    cursor = None
    try:
        conn = psycopg2.connect(database="mydatabase", user="myuser", password="mypassword", host="localhost")
        cursor = conn.cursor()
        cursor.execute("SELECT status FROM users WHERE id = %s", (user_id,))
        result = cursor.fetchone()
        if result:
            return result[0]
        return None
    except (Exception, psycopg2.Error) as error:
        print("PostgreSQL'den veri alma hatası", error) # Hata kaydı
        return None
    finally:
        if cursor:
            cursor.close()
        if conn:
            conn.close()