uploadoss 0.3__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of uploadoss might be problematic. Click here for more details.

@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.1
2
+ Name: uploadoss
3
+ Version: 0.3.2
4
+ Summary: Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS
5
+ Author: Binghe
6
+ Project-URL: Source, https://github.com/binghexmo/uploadoss/
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.txt
9
+
10
+ # Uploadoss
11
+ Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS
12
+
13
+
14
+ ## Installation
15
+ download uploadoss-0.1.tar.gz
16
+ https://pypi.org/project/uploadoss/#files
17
+ pip install uploadoss-0.1.tar.gz
18
+
19
+ ## Usage
20
+ Some simple things you can do with uploadoss
21
+ ```
22
+ #upload local file(Logs, CSV, and their gzip compression) to Alibaba Cloud OSS
23
+
24
+ from uploadoss import uploadoss
25
+ conf_path = 'C:\demo\oss\conf.ini'
26
+ bucket = uploadoss.getossbucket(conf_path)
27
+ # Directory of local files
28
+ local_path = r'C:\\demo\\data\\file\\'
29
+ # The file name in the local directory, also used as the file name on the OSS side
30
+ file_name = 'test1.log.gz'
31
+ # OSS Directory
32
+ oss_path = 'xxx/testlocalfile/'
33
+ result = uploadoss.file_to_oss(bucket,local_path = local_path,file_name = file_name,oss_path = oss_path)
34
+ print('http status: {0}'.format(result.status))
35
+
36
+ # Through a single SQL statement
37
+
38
+ conn = uploadoss.getmysqlconn(conf_path=conf_path)
39
+ #
40
+ sql_text = 'select * from bigdata_demo.event_info limit 1'
41
+ # The file where the SQL query results are stored, also serving as the file name on the OSS side
42
+ file_name = 'sql_text.csv.gz'
43
+ # OSS Directory
44
+ oss_path = 'xxx/testsqltext/dt=20230926/'
45
+ result = uploadoss.mysql_to_oss_table(conn=conn,bucket=bucket,local_path=local_path,file_name=file_name,sql_text=sql_text,oss_path = oss_path)
46
+ print('http status: {0}'.format(result.status))
47
+
48
+
49
+ # Through a multiple SQL statements,The separator is \001 ,e.g. event_info\001SQL_TEXT
50
+ table_conf_list=r'C:\\demo\\oss\\table_config.txt'
51
+ result = uploadoss.mysql_to_oss_list(conf_path = conf_path,local_path = local_path,oss_dire_path = oss_dire_path,table_list_conf = table_conf_list )
52
+
53
+ ```
@@ -1,8 +1,12 @@
1
1
  from setuptools import setup, find_packages
2
+ import codecs
3
+
4
+ # with open('README.md') as f:
5
+ # long_description = f.read()
2
6
 
3
7
  setup(
4
8
  name='uploadoss',
5
- version='0.3',
9
+ version='0.3.2',
6
10
  author='Binghe',
7
11
  description='Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS',
8
12
  packages=find_packages(),
@@ -12,5 +16,10 @@ setup(
12
16
  'pymysql',
13
17
  'configparser'
14
18
  ],
19
+ project_urls={
20
+ 'Source': 'https://github.com/binghexmo/uploadoss/',
21
+ },
22
+ long_description=(codecs.open("README.md", encoding='utf-8').read()),
23
+ long_description_content_type="text/markdown"
15
24
  )
16
25
 
@@ -5,6 +5,14 @@ import pandas as pd
5
5
  from configparser import ConfigParser
6
6
  import os
7
7
 
8
+
9
+ """
10
+ Mysql数据库批量操作,内部对CSV进行GZIP压缩处理,将多个表的数据导出并上传到Ali OSS 指定目录
11
+ :param conf_path: config file full path
12
+ :local_path: 本地文件位置,用于存放数据库导出的数据
13
+ :oss_dire_path: Ali OSS目录名称
14
+ :table_list_conf: config file full path,每个表和sql文本使用固定的分隔符\001
15
+ """
8
16
  def mysql_to_oss_list(conf_path,local_path,oss_dire_path,table_list_conf):
9
17
  config = ConfigParser()
10
18
  config.read(conf_path)
@@ -77,6 +85,13 @@ def oss_upload_file(local_file,oss_path,file_name,bucket):
77
85
  result = bucket.put_object(oss_path+file_name, file_obj)
78
86
  return result
79
87
 
88
+ """
89
+ 上传单个文件到Ali OSS 指定目录
90
+ :param bucket: Ali bucket,getossbucket() 返回值
91
+ :local_path: 本地文件位置
92
+ :file_name: 本地文件名称,同时也作为OSS端文件名称
93
+ :oss_path: 文件需要上传到的目录
94
+ """
80
95
  def file_to_oss(bucket,local_path,file_name,oss_path):
81
96
 
82
97
  local_file = local_path + file_name
@@ -87,7 +102,10 @@ def file_to_oss(bucket,local_path,file_name,oss_path):
87
102
  return result
88
103
 
89
104
 
90
- # Get OSS Bucket
105
+ """
106
+ 返回 OSS Bucket
107
+ :param conf_path: config file full path
108
+ """
91
109
  def getossbucket(conf_path):
92
110
 
93
111
  config = ConfigParser()
@@ -103,7 +121,10 @@ def getossbucket(conf_path):
103
121
  bucket = oss2.Bucket(auth, endpoint, bucket)
104
122
 
105
123
  return bucket
106
-
124
+ """
125
+ 返回 pymysql conn
126
+ :param conf_path: config file full path
127
+ """
107
128
  def getmysqlconn(conf_path):
108
129
  config = ConfigParser()
109
130
  config.read(conf_path)
@@ -118,7 +139,15 @@ def getmysqlconn(conf_path):
118
139
  conn = pymysql.connect(host=host, port=port, user=user, password=password, database=database,charset=charset)
119
140
  return conn
120
141
 
121
- # 数据库单次操作
142
+ """
143
+ 数据库单次操作,内部对CSV进行GZIP压缩处理,文件名格式.csv.gz
144
+ :param conn: pymysql conn
145
+ :param bucket: Ali bucket,getossbucket() 返回值
146
+ :local_path: 本地文件位置
147
+ :file_name: 本地文件名称,同时也作为OSS端文件名称
148
+ :sql_text: sql
149
+ :oss_path: 文件需要上传到的目录
150
+ """
122
151
  def mysql_to_oss_table(conn,bucket,local_path,file_name,sql_text,oss_path):
123
152
 
124
153
  df = pd.read_sql(sql_text,conn)
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.1
2
+ Name: uploadoss
3
+ Version: 0.3.2
4
+ Summary: Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS
5
+ Author: Binghe
6
+ Project-URL: Source, https://github.com/binghexmo/uploadoss/
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE.txt
9
+
10
+ # Uploadoss
11
+ Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS
12
+
13
+
14
+ ## Installation
15
+ download uploadoss-0.1.tar.gz
16
+ https://pypi.org/project/uploadoss/#files
17
+ pip install uploadoss-0.1.tar.gz
18
+
19
+ ## Usage
20
+ Some simple things you can do with uploadoss
21
+ ```
22
+ #upload local file(Logs, CSV, and their gzip compression) to Alibaba Cloud OSS
23
+
24
+ from uploadoss import uploadoss
25
+ conf_path = 'C:\demo\oss\conf.ini'
26
+ bucket = uploadoss.getossbucket(conf_path)
27
+ # Directory of local files
28
+ local_path = r'C:\\demo\\data\\file\\'
29
+ # The file name in the local directory, also used as the file name on the OSS side
30
+ file_name = 'test1.log.gz'
31
+ # OSS Directory
32
+ oss_path = 'xxx/testlocalfile/'
33
+ result = uploadoss.file_to_oss(bucket,local_path = local_path,file_name = file_name,oss_path = oss_path)
34
+ print('http status: {0}'.format(result.status))
35
+
36
+ # Through a single SQL statement
37
+
38
+ conn = uploadoss.getmysqlconn(conf_path=conf_path)
39
+ #
40
+ sql_text = 'select * from bigdata_demo.event_info limit 1'
41
+ # The file where the SQL query results are stored, also serving as the file name on the OSS side
42
+ file_name = 'sql_text.csv.gz'
43
+ # OSS Directory
44
+ oss_path = 'xxx/testsqltext/dt=20230926/'
45
+ result = uploadoss.mysql_to_oss_table(conn=conn,bucket=bucket,local_path=local_path,file_name=file_name,sql_text=sql_text,oss_path = oss_path)
46
+ print('http status: {0}'.format(result.status))
47
+
48
+
49
+ # Through a multiple SQL statements,The separator is \001 ,e.g. event_info\001SQL_TEXT
50
+ table_conf_list=r'C:\\demo\\oss\\table_config.txt'
51
+ result = uploadoss.mysql_to_oss_list(conf_path = conf_path,local_path = local_path,oss_dire_path = oss_dire_path,table_list_conf = table_conf_list )
52
+
53
+ ```
uploadoss-0.3/PKG-INFO DELETED
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: uploadoss
3
- Version: 0.3
4
- Summary: Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS
5
- Author: Binghe
6
- License-File: LICENSE.txt
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: uploadoss
3
- Version: 0.3
4
- Summary: Uploadoss is the general module of uploading database data and local files to the Alibaba Cloud OSS
5
- Author: Binghe
6
- License-File: LICENSE.txt
File without changes
File without changes
File without changes
File without changes