26 lines
552 B
Python
26 lines
552 B
Python
import mysql.connector
|
|
|
|
# Establish a connection to the database
|
|
connection = mysql.connector.connect(
|
|
host="server1.home",
|
|
user="sascha",
|
|
password="mgltoJtmmDnKJ86LltsGdw",
|
|
database="regulus"
|
|
)
|
|
|
|
# Create a cursor object to execute SQL queries
|
|
db = connection.cursor()
|
|
|
|
# Example query
|
|
db.execute('SELECT AccountName,Street,City,ZIP FROM Accounts LIMIT 100')
|
|
|
|
# Fetch the results
|
|
accounts = db.fetchall()
|
|
|
|
# Process the results
|
|
for account in accounts:
|
|
print(account)
|
|
|
|
# Close the cursor and connection
|
|
db.close()
|
|
connection.close() |