Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Amazon-Selection-Data
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abel_cjy
Amazon-Selection-Data
Commits
0bf384dc
Commit
0bf384dc
authored
Jul 16, 2026
by
hejiangming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
内部asin 评分评论数导出到mysql
parent
f3bef6ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
dwt_self_asin_detail_rating.py
Pyspark_job/sqoop_export/dwt_self_asin_detail_rating.py
+4
-2
No files found.
Pyspark_job/sqoop_export/dwt_self_asin_detail_rating.py
View file @
0bf384dc
...
@@ -7,7 +7,8 @@ from utils.secure_db_client import get_remote_engine
...
@@ -7,7 +7,8 @@ from utils.secure_db_client import get_remote_engine
def
export_data
(
site_name
,
date_type
,
date_info
):
def
export_data
(
site_name
,
date_type
,
date_info
):
engine
=
get_remote_engine
(
engine
=
get_remote_engine
(
site_name
=
"us"
,
# -> database "selection"
site_name
=
"us"
,
# -> database "selection"
db_type
=
"postgresql_cluster"
,
# -> 服务端 alias "mysql"
# db_type="postgresql_cluster", # 原导出到 pg 集群,改为 MySQL,不再维护
db_type
=
"mysql"
,
# -> 阿里云 MySQL
# user="fangxingjun", # -> 服务端 alias "mysql"
# user="fangxingjun", # -> 服务端 alias "mysql"
# user_token="5f1b2e9c3a4d7f60" # 可不传,走默认
# user_token="5f1b2e9c3a4d7f60" # 可不传,走默认
)
)
...
@@ -22,7 +23,8 @@ def export_data(site_name, date_type, date_info):
...
@@ -22,7 +23,8 @@ def export_data(site_name, date_type, date_info):
# sql_drop = f"drop table if exists {import_table};"
# sql_drop = f"drop table if exists {import_table};"
# sql_create = f"create table {import_table} like {target_table};"
# sql_create = f"create table {import_table} like {target_table};"
sql_drop
=
f
"drop table if exists {import_table};"
# 删除依赖
sql_drop
=
f
"drop table if exists {import_table};"
# 删除依赖
sql_create
=
f
"""CREATE TABLE {import_table} (LIKE {target_table} INCLUDING ALL);"""
# pg
# sql_create = f"""CREATE TABLE {import_table} (LIKE {target_table} INCLUDING ALL);""" # pg 语法,MySQL 不支持,改为下面的 like 写法
sql_create
=
f
"create table {import_table} like {target_table};"
# MySQL:复制目标表结构建临时表
engine
.
execute
(
sql_drop
)
engine
.
execute
(
sql_drop
)
engine
.
execute
(
sql_create
)
engine
.
execute
(
sql_create
)
print
(
f
"sql_drop: {sql_drop}"
)
print
(
f
"sql_drop: {sql_drop}"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment