python_weather/spark/data/data.py

48 lines
1.1 KiB
Python
Raw Permalink Normal View History

from pathlib import Path
data_path = Path("data")
hdfs_path = "/user/spark/data/"
def create_local_path(_file_path: str) -> Path:
return data_path / _file_path
def create_hdfs_path(_file_path: str) -> str:
return f"{hdfs_path}{_file_path}"
data_hour_csv = "data_hour.csv"
data_now_csv = "data_now.csv"
data_day_csv = "data_day.csv"
data_next_csv = "data_next.csv"
data_hour_file = create_local_path(data_hour_csv)
data_now_file = create_local_path(data_now_csv)
data_day_file = create_local_path(data_day_csv)
data_next_file = create_local_path(data_next_csv)
data_hour_hdfs = create_hdfs_path(data_hour_csv)
data_now_hdfs = create_hdfs_path(data_now_csv)
data_day_hdfs = create_hdfs_path(data_day_csv)
data_next_hdfs = create_hdfs_path(data_next_csv)
datas = [
data_hour_file,
data_next_file,
data_now_file,
data_day_file,
]
class Mysql:
HOST = "pyh03"
PORT = 3306
USERNAME = "root"
PASSWORD = "123456"
DATABASE = "weather"
mysql_jdbc_uri = f"jdbc:mysql://{Mysql.HOST}:{Mysql.PORT}/{Mysql.DATABASE}?characterEncoding=utf8&useSSL=false"
mysql_jdbc_prop = {"user": Mysql.USERNAME, "password": Mysql.PASSWORD}