scripts
This commit is contained in:
@@ -7,13 +7,13 @@ import mysql.connector
|
||||
from minio import Minio
|
||||
from minio.error import S3Error
|
||||
|
||||
minio_public_url = 'http://58.215.212.230:8005/oss/'
|
||||
minio_public_url = '/oss/'
|
||||
# MySQL 连接配置
|
||||
db_config = {
|
||||
# 'host': 'physical-mysql',
|
||||
# 'port': 3306,
|
||||
'host': '192.168.50.100',
|
||||
'port': 23306,
|
||||
'host': '127.0.0.1',
|
||||
'port': 3306,
|
||||
# 'host': '192.168.50.100',
|
||||
# 'port': 23306,
|
||||
'user': 'root',
|
||||
'password': '123456',
|
||||
'database': 'physical-boot'
|
||||
@@ -21,8 +21,8 @@ db_config = {
|
||||
|
||||
# minio 配置
|
||||
minio_client = Minio(
|
||||
# "physical-minio:9000", # MinIO服务器地址或IP
|
||||
"192.168.50.100:29000", # MinIO服务器地址或IP
|
||||
"127.0.0.1:9000", # MinIO服务器地址或IP
|
||||
# "192.168.50.100:29000", # MinIO服务器地址或IP
|
||||
access_key="root", # 替换为你的Access Key
|
||||
secret_key="12345678", # 替换为你的Secret Key
|
||||
secure=False # 如果使用的是http则为False
|
||||
@@ -38,7 +38,18 @@ def get_md5(input_string):
|
||||
# 返回MD5值的十六进制字符串
|
||||
return md5_obj.hexdigest()
|
||||
|
||||
|
||||
def fetch_db_import_record(connection,data):
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
"""保存数据到 MySQL 数据库"""
|
||||
insert_query = """select count(1) from `nasa_data_record` where `id`= %s;"""
|
||||
cursor.execute(insert_query, data)
|
||||
result = cursor.fetchone()
|
||||
return result[0]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
cursor.close()
|
||||
def save_to_db_import_record(connection,data):
|
||||
cursor = connection.cursor()
|
||||
try:
|
||||
@@ -81,10 +92,10 @@ def upload_to_minio(connection,folder_path,type):
|
||||
object_name = f"{type}/{folder_name}/{file_name}"
|
||||
try:
|
||||
# 上传文件到 MinIO
|
||||
url=minio_client.fput_object(bucket_name, object_name, file_path)
|
||||
# url=minio_client.fput_object(bucket_name, object_name, file_path)
|
||||
print(f"已上传: {file_path} -> {bucket_name}/{object_name}")
|
||||
# file_id = get_md5(object_name)
|
||||
file_ids.append({file_name:os.path.join(minio_public_url,bucket_name,url.object_name)})
|
||||
file_ids.append({file_name:os.path.join(minio_public_url,bucket_name,object_name)})
|
||||
# db_file = [file_id, file_name,
|
||||
# minio_public_url + bucket_name + '/' + object_name, 'admin', datetime.now()]
|
||||
# save_to_db_oss_file(connection,db_file)
|
||||
|
||||
Reference in New Issue
Block a user