echoss-db 1.0.8__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.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ exclude config/
5
+ include tutorial *.ipynb
6
+ recursive-exclude * __pycache__/
7
+ recursive-exclude * *.log *.log.*
8
+ recursive-exclude * .*.un~
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: echoss_db
3
+ Version: 1.0.8
4
+ Summary: echoss AI Bigdata Solution - Database Query Package
5
+ Home-page: https://github.com/12cmlab/echoss-query
6
+ Author: ckkim
7
+ Author-email: ckkim@12cm.co.kr
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >3.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: pandas>=1.5.3
14
+ Requires-Dist: pymongo>=4.3.3
15
+ Requires-Dist: PyMySQL>=1.0.2
16
+ Requires-Dist: PyYAML>=6.0
17
+ Requires-Dist: opensearch-py>=2.2.0
18
+ Requires-Dist: echoss-fileformat>=1.1.2
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
28
+
29
+ # echoss_db
30
+ -------------
31
+ MySQL, MongoDB, Opensearch compatible query access package
32
+
33
+ ## Prepare
34
+ 사용 전 config(인증 정보) 의 유무를 확인한 뒤 사용해야한다.
35
+ config file example:
36
+ ```
37
+ mysql:
38
+ user : <user_id>
39
+ passwd : <pass code>
40
+ host : <IP addrress or domain>
41
+ port : :<network port number>
42
+ db : <schema name>
43
+ charset : utf8
44
+
45
+ mongo:
46
+ host : <IP addrress or domain>
47
+ port :<network port number>
48
+ db : <database name>
49
+
50
+ elastic:
51
+ user : <user_id>
52
+ passwd : <pass code>
53
+ host : <IP addrress or domain>
54
+ port : :<network port number>
55
+ scheme : <http or https>
56
+ ```
57
+
58
+ ## Installaion
59
+ -------------
60
+ To install this package, please use Python 3.8 or higher.
61
+
62
+ ```
63
+ pip install -U echoss-db
64
+ ```
65
+
66
+ ## Quick Start
67
+
68
+ ### Import package and class
69
+ ```
70
+ from echoss_db import MysqlQuery, MongoQuery, ElasticSearch
71
+
72
+ mysql = MysqlQuery('CONFIG_FILE_PATH' or dict)
73
+ mongo = MongoQuery('CONFIG_FILE_PATH' or dict)
74
+ elastic = ElasticSearch('CONFIG_FILE_PATH' or dict)
75
+ ```
76
+
77
+ ### MySQL
78
+ -------------
79
+ ```
80
+ # CREATE
81
+ mysql.create('QUERY_STRING')
82
+
83
+ # DROP
84
+ mysql.drop('QUERY_STRING')
85
+
86
+ # TRUNCATE
87
+ mysql.truncate('QUERY_STRING')
88
+
89
+ # ALTER
90
+ mysql.alter('QUERY_STRING')
91
+
92
+ # SELECT
93
+ mysql.select('QUERY_STRING', params=None) -> dataframe
94
+ mysql.select_one('QUERY_STRING', params=None) -> dict
95
+ mysql.select_list('QUERY_STRING', params=None) -> list(dict)
96
+ mysql.faster_select('QUERY_STRING', params=None) -> dataframe
97
+
98
+ # INSERT without params
99
+ mysql.insert('QUERY_STRING', params=None) -> int
100
+ # INSERT with tuple
101
+ mysql.insert('QUERY_STRING', params) -> int
102
+ # INSERT with list[tuple]
103
+ mysql.insert('QUERY_STRING', params_list) -> int
104
+
105
+ # UPDATE
106
+ mysql.update('QUERY_STRING', params=None) -> int
107
+
108
+ # DELETE
109
+ mysql.delete('QUERY_STRING', params=None) -> int
110
+
111
+ # show Database
112
+ mysql.databases()
113
+
114
+ # show Tables
115
+ mysql.tables()
116
+
117
+ # Ping
118
+ mysql.ping()
119
+
120
+ # get connection cursor
121
+ mysql.conn_cursor(cursorclass=None)
122
+
123
+ # Close
124
+ # crash process close
125
+ mysql.close()
126
+
127
+ # debug query : default True
128
+ mysql.debug_query(False)
129
+ ```
130
+
131
+ ### MongoDB
132
+ -------------
133
+ ```
134
+ # show Database
135
+ mongo.databases()
136
+
137
+ # show Collections
138
+ mongo.collections()
139
+
140
+ # Ping
141
+ mongo.ping()
142
+
143
+ # SELECT
144
+ mongo.select('COLLECTION_NAME','QUERY_STRING or DICTIONARY') -> pd.Dataframe
145
+
146
+ # INSERT
147
+ mongo.insert('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
148
+ mongo.insert_many('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
149
+
150
+ # UPDATE
151
+ mongo.update('COLLECTION_NAME','FILTER_STRING or DICTIONARY', 'UPDATE_STRING or DICTIONARY')
152
+ mongo.update_many('COLLECTION_NAME','FILTER_STRING or DICTIONARY', 'UPDATE_STRING or DICTIONARY')
153
+
154
+ # DELETE
155
+ mongo.delete('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
156
+ mongo.delete_many('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
157
+
158
+ ```
159
+
160
+ ### ElasticSearch
161
+ -------------
162
+ ```
163
+ # CREATE
164
+ elastic.index(index='INDEX_NAME')
165
+
166
+ # DROP
167
+ elastic.delete_index(index='INDEX_NAME')
168
+
169
+ # SELECT
170
+ elastic.search(body=query) -> any
171
+ elastic.search_list(body=query, fetch_all=True) -> list
172
+ elastic.search_dataframe(body=query, fetch_all=True) -> dataframe
173
+ elastic.search_field(field='FIELD_NAME',value='VALUE') -> list
174
+
175
+ # INSERT
176
+ elastic.create(id='ID', body='JSON_BODY')
177
+
178
+ #UPDATE
179
+ elastic.update(id='ID', body='JSON_BODY')
180
+
181
+ #DELETE
182
+ elastic.delete(id='ID')
183
+
184
+ # Ping
185
+ elastic.ping()
186
+
187
+ # Connection Information
188
+ elastic.info()
189
+ ```
190
+
191
+ ### Code Quality
192
+ When creating new functions, please follow the Google style Python docstrings. See example below:
193
+ ```
194
+ def example_function(param1: int, param2: str) -> bool:
195
+ """Example function that does something.
196
+
197
+ Args:
198
+ param1: The first parameter.
199
+ param2: The second parameter.
200
+
201
+ Returns:
202
+ The return value. True for success, False otherwise.
203
+
204
+ """
205
+ ```
206
+
207
+ ## Version history
208
+ v0.1.0 initial version
209
+ v0.1.1 echoss_logger include
210
+ v0.1.7 mysql support query with params. return cursor.rowcount for insert/update/delete query
211
+ v1.0.0 mysql support query with list params
212
+ v1.0.1 elastic search_list fetch_all option, mongo support insert_many, delete_many, update_many method
213
+ v1.0.2 mysql reuse cursor
214
+ v1.0.7 echoss-query last version
215
+ v1.0.8 change package name to echoss-db
@@ -0,0 +1,187 @@
1
+ # echoss_db
2
+ -------------
3
+ MySQL, MongoDB, Opensearch compatible query access package
4
+
5
+ ## Prepare
6
+ 사용 전 config(인증 정보) 의 유무를 확인한 뒤 사용해야한다.
7
+ config file example:
8
+ ```
9
+ mysql:
10
+ user : <user_id>
11
+ passwd : <pass code>
12
+ host : <IP addrress or domain>
13
+ port : :<network port number>
14
+ db : <schema name>
15
+ charset : utf8
16
+
17
+ mongo:
18
+ host : <IP addrress or domain>
19
+ port :<network port number>
20
+ db : <database name>
21
+
22
+ elastic:
23
+ user : <user_id>
24
+ passwd : <pass code>
25
+ host : <IP addrress or domain>
26
+ port : :<network port number>
27
+ scheme : <http or https>
28
+ ```
29
+
30
+ ## Installaion
31
+ -------------
32
+ To install this package, please use Python 3.8 or higher.
33
+
34
+ ```
35
+ pip install -U echoss-db
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ### Import package and class
41
+ ```
42
+ from echoss_db import MysqlQuery, MongoQuery, ElasticSearch
43
+
44
+ mysql = MysqlQuery('CONFIG_FILE_PATH' or dict)
45
+ mongo = MongoQuery('CONFIG_FILE_PATH' or dict)
46
+ elastic = ElasticSearch('CONFIG_FILE_PATH' or dict)
47
+ ```
48
+
49
+ ### MySQL
50
+ -------------
51
+ ```
52
+ # CREATE
53
+ mysql.create('QUERY_STRING')
54
+
55
+ # DROP
56
+ mysql.drop('QUERY_STRING')
57
+
58
+ # TRUNCATE
59
+ mysql.truncate('QUERY_STRING')
60
+
61
+ # ALTER
62
+ mysql.alter('QUERY_STRING')
63
+
64
+ # SELECT
65
+ mysql.select('QUERY_STRING', params=None) -> dataframe
66
+ mysql.select_one('QUERY_STRING', params=None) -> dict
67
+ mysql.select_list('QUERY_STRING', params=None) -> list(dict)
68
+ mysql.faster_select('QUERY_STRING', params=None) -> dataframe
69
+
70
+ # INSERT without params
71
+ mysql.insert('QUERY_STRING', params=None) -> int
72
+ # INSERT with tuple
73
+ mysql.insert('QUERY_STRING', params) -> int
74
+ # INSERT with list[tuple]
75
+ mysql.insert('QUERY_STRING', params_list) -> int
76
+
77
+ # UPDATE
78
+ mysql.update('QUERY_STRING', params=None) -> int
79
+
80
+ # DELETE
81
+ mysql.delete('QUERY_STRING', params=None) -> int
82
+
83
+ # show Database
84
+ mysql.databases()
85
+
86
+ # show Tables
87
+ mysql.tables()
88
+
89
+ # Ping
90
+ mysql.ping()
91
+
92
+ # get connection cursor
93
+ mysql.conn_cursor(cursorclass=None)
94
+
95
+ # Close
96
+ # crash process close
97
+ mysql.close()
98
+
99
+ # debug query : default True
100
+ mysql.debug_query(False)
101
+ ```
102
+
103
+ ### MongoDB
104
+ -------------
105
+ ```
106
+ # show Database
107
+ mongo.databases()
108
+
109
+ # show Collections
110
+ mongo.collections()
111
+
112
+ # Ping
113
+ mongo.ping()
114
+
115
+ # SELECT
116
+ mongo.select('COLLECTION_NAME','QUERY_STRING or DICTIONARY') -> pd.Dataframe
117
+
118
+ # INSERT
119
+ mongo.insert('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
120
+ mongo.insert_many('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
121
+
122
+ # UPDATE
123
+ mongo.update('COLLECTION_NAME','FILTER_STRING or DICTIONARY', 'UPDATE_STRING or DICTIONARY')
124
+ mongo.update_many('COLLECTION_NAME','FILTER_STRING or DICTIONARY', 'UPDATE_STRING or DICTIONARY')
125
+
126
+ # DELETE
127
+ mongo.delete('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
128
+ mongo.delete_many('COLLECTION_NAME','QUERY_STRING or DICTIONARY')
129
+
130
+ ```
131
+
132
+ ### ElasticSearch
133
+ -------------
134
+ ```
135
+ # CREATE
136
+ elastic.index(index='INDEX_NAME')
137
+
138
+ # DROP
139
+ elastic.delete_index(index='INDEX_NAME')
140
+
141
+ # SELECT
142
+ elastic.search(body=query) -> any
143
+ elastic.search_list(body=query, fetch_all=True) -> list
144
+ elastic.search_dataframe(body=query, fetch_all=True) -> dataframe
145
+ elastic.search_field(field='FIELD_NAME',value='VALUE') -> list
146
+
147
+ # INSERT
148
+ elastic.create(id='ID', body='JSON_BODY')
149
+
150
+ #UPDATE
151
+ elastic.update(id='ID', body='JSON_BODY')
152
+
153
+ #DELETE
154
+ elastic.delete(id='ID')
155
+
156
+ # Ping
157
+ elastic.ping()
158
+
159
+ # Connection Information
160
+ elastic.info()
161
+ ```
162
+
163
+ ### Code Quality
164
+ When creating new functions, please follow the Google style Python docstrings. See example below:
165
+ ```
166
+ def example_function(param1: int, param2: str) -> bool:
167
+ """Example function that does something.
168
+
169
+ Args:
170
+ param1: The first parameter.
171
+ param2: The second parameter.
172
+
173
+ Returns:
174
+ The return value. True for success, False otherwise.
175
+
176
+ """
177
+ ```
178
+
179
+ ## Version history
180
+ v0.1.0 initial version
181
+ v0.1.1 echoss_logger include
182
+ v0.1.7 mysql support query with params. return cursor.rowcount for insert/update/delete query
183
+ v1.0.0 mysql support query with list params
184
+ v1.0.1 elastic search_list fetch_all option, mongo support insert_many, delete_many, update_many method
185
+ v1.0.2 mysql reuse cursor
186
+ v1.0.7 echoss-query last version
187
+ v1.0.8 change package name to echoss-db
@@ -0,0 +1,3 @@
1
+ from .mysql_query import MysqlQuery
2
+ from .mongo_query import MongoQuery
3
+ from .elastic_search import ElasticSearch