"""
This Python code snippet is connecting to a MySQL database
using the `mysql.connector` library and fetching data from a table named `scimag`
Here is a breakdown of what the code is doing:
"""

import netrc

import mysql.connector

NETRC_FILE = "/home/mtuszowski/.netrc"
netrc_mod = netrc.netrc(NETRC_FILE)
REMOTE_HOST_NAME = "192.168.1.192"
authTokens = netrc_mod.authenticators(REMOTE_HOST_NAME)

mydb = mysql.connector.connect(
    host=REMOTE_HOST_NAME,
    user=authTokens[0],
    password=authTokens[2],
    database="scihubdois",
)
mycursor = mydb.cursor()

mycursor.execute("SELECT * FROM scimag WHERE Title Like 'spider%'")
for x in mycursor:
    print(x)
