import pandas as pd
from sqlalchemy import create_engine
import matplotlib.pyplot as plt
import re
import nltk
from rake_nltk import Rake
from rake_nltk import Metric
Mysql_arguments = {
    'user': 'adv_yswg',
    'password': 'HCL1zcUgQesaaXNLbL37O5KhpSAy0c',
    'host': 'rm-wz9yg9bsb2zf01ea4yo.mysql.rds.aliyuncs.com',
    'port': 3306,
    'database': 'selection',
    'charset': 'utf8mb4',
}
def get_country_engine(site_name="us"):
    if site_name == 'us':
        db_ = 'mysql+pymysql://{}:{}@{}:{}/{}?charset={}'.format(*Mysql_arguments.values())
    else:
        Mysql_arguments["database"] = f"selection_{site_name}"
        db_ = 'mysql+pymysql://{}:{}@{}:{}/{}?charset={}'.format(*Mysql_arguments.values())
    engine = create_engine(db_)  # , pool_recycle=3600
    return engine
engine = get_country_engine()


# sql =  f"select asin, content, rating from us_asin_comment order by asin limit 10000;"
sql =  f"select asin, content, rating from us_asin_comment where asin='B00B0RD2RA';"
df_asin_comment = pd.read_sql(sql, con=engine)
print(df_asin_comment.head())