import cx_Oracle

def connect_to_oracle():
    try:
        username = 'student'
        password = 'student'
        hostname = 'localhost'
        port = 1521
        sid = 'xe'
        
        dsn = cx_Oracle.makedsn(hostname, port, sid=sid)
        connection = cx_Oracle.connect(user=username, password=password, dsn=dsn)
        
        print("Подключение к Oracle XE успешно!")
        
        return connection

    except cx_Oracle.DatabaseError as e:
        error, = e.args
        print(f"Ошибка подключения к базе данных: {error.message}")
        return None

if __name__ == "__main__":
    conn = connect_to_oracle()
    if conn:
        conn.close()