diff --git a/README.md b/README.md index 994aa02..551a8d5 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,12 @@ Utility to import data into ClickHouse from MySQL (mainly) and/or CSV files Data reader requires **Python 3.x** with additional modules to be installed. -`mysql-replication` package is used for communication with MySQL: +`MySQLdb` package is used for communication with MySQL: +```bash +pip install mysqlclient +``` + +`mysql-replication` package is used for communication with MySQL also: [https://github.com/noplay/python-mysql-replication](https://github.com/noplay/python-mysql-replication) ```bash pip install mysql-replication @@ -43,6 +48,7 @@ pip install mysql-replication pip install clickhouse-driver ``` + Also the following (at least one of) MySQL privileges are required for this operation: `SUPER`, `REPLICATION CLIENT` ```mysql @@ -133,7 +139,7 @@ Options description # Performance `pypy` significantly improves performance. You should try it. -For example you can start with [Portable PyPy distribution for Linux](https://github.com/squeaky-pl/portable-pypy#portable-pypy-distribution-for-linux) +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] Unpack it into your place of choice. ```bash @@ -159,6 +165,17 @@ Install required modules pypy3.5-5.9-beta-linux_x86_64-portable/bin/pip3 install mysql-replication pypy3.5-5.9-beta-linux_x86_64-portable/bin/pip3 install clickhouse-driver ``` +`mysqlclient` may require to install `libmysqlclient-dev` and `gcc` +```bash +pypy3.5-5.9-beta-linux_x86_64-portable/bin/pip3 install mysqlclient +``` +Install them if need be +```bash +sudo apt-get install libmysqlclient-dev +``` +```bash +sudo apt-get install gcc +``` Now you can run data reader via `pypy` ```bash diff --git a/src/tablebuilder.py b/src/tablebuilder.py index 7a7937a..1f4f93e 100644 --- a/src/tablebuilder.py +++ b/src/tablebuilder.py @@ -17,7 +17,7 @@ class TableBuilder(object): dbs = None tables = None - def __init__(self, host, port, user, password=None, dbs=None, tables=None): + def __init__(self, host=None, port=None, user=None, password=None, dbs=None, tables=None): self.host = host self.port = port self.user = user @@ -221,14 +221,15 @@ def map_type(self, mysql_type, nullable=False): return ch_type if __name__ == '__main__': - tb = TableBuilder() - templates = tb.templates( + tb = TableBuilder( host='127.0.0.1', user='reader', password='qwerty', - db='db', -# tables='datatypes, enum_datatypes, json_datatypes', + dbs=['db'], + # tables='datatypes, enum_datatypes, json_datatypes', tables=['datatypes', 'enum_datatypes', 'json_datatypes'], ) - for table in templates: - print(table, '=', templates[table]) + templates = tb.templates() + for db in templates: + for table in templates[db]: + print(table, '=', templates[db][table])