mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 13:34:40 +00:00
f55c4ce1a7
Additional lines of code 1 AAA
27 lines
668 B
Python
27 lines
668 B
Python
"""
|
|
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)
|