27 lines
585 B
Python
27 lines
585 B
Python
import mysql.connector
|
|
import os
|
|
import dotenv
|
|
|
|
dotenv.load_dotenv()
|
|
|
|
# Database connection
|
|
dbargs = {
|
|
'host':os.getenv('DB_HOST'),
|
|
'user':os.getenv('DB_USER'),
|
|
'password':os.getenv('DB_PASSWORD'),
|
|
'database':os.getenv('DB_NAME')
|
|
}
|
|
|
|
def get_website_data(domain):
|
|
connection = mysql.connector.connect(**dbargs)
|
|
cursor = connection.cursor()
|
|
cursor.execute("""
|
|
SELECT * FROM site WHERE domain = %s
|
|
""", (domain,))
|
|
data = cursor.fetchall()
|
|
cursor.close()
|
|
connection.close()
|
|
|
|
if data == []:
|
|
return ""
|
|
return data[0][2] |