You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.3 KiB
Python

username = "doadmin"
password = "AVNS_2qeFJuiGRpBQXkJjlA6"
host = "storysave-do-user-13308724-0.c.db.ondigitalocean.com"
port = 25060
database = "storysave"
sslmode = "REQUIRED"
def gen_connection():
import mysql.connector
print("Connecting to database")
newDB = mysql.connector.connect(host=host, user=username, password=password, database=database, port=port)
print("Connected to database")
return newDB, newDB.cursor()
def get_storage():
from BunnyCDN.Storage import Storage
return Storage('345697f9-d9aa-4a6b-a5ec8bffc16d-ceaf-453e', 'storysave')
def get_custom_storage():
from bunny import Storage
return Storage('345697f9-d9aa-4a6b-a5ec8bffc16d-ceaf-453e', 'storysave')
def get_redis_connection():
from redis import Redis
REDIS_HOST = "192.168.0.27"
REDIS_PORT = 30059
REDIS_PASSWORD = "7U6zXN96xNg$8BnPd&eE"
try:
client = Redis(
host=REDIS_HOST,
port=REDIS_PORT,
password=REDIS_PASSWORD,
decode_responses=True
)
response = client.ping()
if response:
print("Connected to Redis successfully!")
return client
else:
print("Failed to connect to Redis!")
return None
except Exception as e:
print(f"An error occurred: {e}")
return None