Files
conjurer/test_data_retrieval.py
T
gitea f55c4ce1a7 Nowy lepszy trunk
Additional lines of code

1

AAA
2024-04-10 14:22:00 +02:00

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)