Skip to content

Commit 69d1acb

Browse files
authored
Merge pull request #41 from sunsingerus/master
more details on required pip modules
2 parents ccd7a7d + 907cba3 commit 69d1acb

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ Utility to import data into ClickHouse from MySQL (mainly) and/or CSV files
3131

3232
Data reader requires **Python 3.x** with additional modules to be installed.
3333

34-
`mysql-replication` package is used for communication with MySQL:
34+
`MySQLdb` package is used for communication with MySQL:
35+
```bash
36+
pip install mysqlclient
37+
```
38+
39+
`mysql-replication` package is used for communication with MySQL also:
3540
[https://github.com/noplay/python-mysql-replication](https://github.com/noplay/python-mysql-replication)
3641
```bash
3742
pip install mysql-replication
@@ -43,6 +48,7 @@ pip install mysql-replication
4348
pip install clickhouse-driver
4449
```
4550

51+
4652
Also the following (at least one of) MySQL privileges are required for this operation: `SUPER`, `REPLICATION CLIENT`
4753

4854
```mysql
@@ -133,7 +139,7 @@ Options description
133139
# Performance
134140

135141
`pypy` significantly improves performance. You should try it.
136-
For example you can start with [Portable PyPy distribution for Linux](https://github.com/squeaky-pl/portable-pypy#portable-pypy-distribution-for-linux)
142+
For example you can start with [Portable PyPy distribution for Linux](https://github.com/squeaky-pl/portable-pypy#portable-pypy-distribution-for-linux) - use (Python 3.x release)[https://github.com/squeaky-pl/portable-pypy#latest-python-35-release]
137143
Unpack it into your place of choice.
138144

139145
```bash
@@ -159,6 +165,17 @@ Install required modules
159165
pypy3.5-5.9-beta-linux_x86_64-portable/bin/pip3 install mysql-replication
160166
pypy3.5-5.9-beta-linux_x86_64-portable/bin/pip3 install clickhouse-driver
161167
```
168+
`mysqlclient` may require to install `libmysqlclient-dev` and `gcc`
169+
```bash
170+
pypy3.5-5.9-beta-linux_x86_64-portable/bin/pip3 install mysqlclient
171+
```
172+
Install them if need be
173+
```bash
174+
sudo apt-get install libmysqlclient-dev
175+
```
176+
```bash
177+
sudo apt-get install gcc
178+
```
162179

163180
Now you can run data reader via `pypy`
164181
```bash

src/tablebuilder.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TableBuilder(object):
1717
dbs = None
1818
tables = None
1919

20-
def __init__(self, host, port, user, password=None, dbs=None, tables=None):
20+
def __init__(self, host=None, port=None, user=None, password=None, dbs=None, tables=None):
2121
self.host = host
2222
self.port = port
2323
self.user = user
@@ -221,14 +221,15 @@ def map_type(self, mysql_type, nullable=False):
221221
return ch_type
222222

223223
if __name__ == '__main__':
224-
tb = TableBuilder()
225-
templates = tb.templates(
224+
tb = TableBuilder(
226225
host='127.0.0.1',
227226
user='reader',
228227
password='qwerty',
229-
db='db',
230-
# tables='datatypes, enum_datatypes, json_datatypes',
228+
dbs=['db'],
229+
# tables='datatypes, enum_datatypes, json_datatypes',
231230
tables=['datatypes', 'enum_datatypes', 'json_datatypes'],
232231
)
233-
for table in templates:
234-
print(table, '=', templates[table])
232+
templates = tb.templates()
233+
for db in templates:
234+
for table in templates[db]:
235+
print(table, '=', templates[db][table])

0 commit comments

Comments
 (0)