-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4686f93
commit a36bad7
Showing
4 changed files
with
20 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# @Author: chunyang.xu | ||
# @Email: [email protected] | ||
# @Date: 2020-06-10 14:40:50 | ||
# @Last Modified time: 2021-08-11 11:10:48 | ||
# @Last Modified time: 2021-08-25 14:46:54 | ||
# @github: https://github.com/longfengpili | ||
|
||
# !/usr/bin/env python3 | ||
|
@@ -61,7 +61,7 @@ def create_partition(self, partition): | |
partition = f"partition by hash (to_days({partition.newname}))" | ||
return partition | ||
|
||
def create(self, columns, indexes, index_part=128, ismultiple_index=True, partition=None): | ||
def create(self, columns, indexes, index_part=128, ismultiple_index=True, partition=None, isdoris=False): | ||
'mysql 暂不考虑索引' | ||
sql = self.create_nonindex(columns) | ||
|
||
|
@@ -77,6 +77,11 @@ def create(self, columns, indexes, index_part=128, ismultiple_index=True, partit | |
partition = self.create_partition(partition) | ||
sql = sql.replace(';', f'\n{partition};') | ||
|
||
if isdoris: | ||
distributed_col = columns[0].newname | ||
distributed = f"distributed by hash({distributed_col})" | ||
sql = sql.replace(';', f'\n{distributed};') | ||
|
||
return sql | ||
|
||
def dumpsql(self, columns, dumpfile, fromtable=None, condition=None): | ||
|
@@ -95,13 +100,14 @@ def loadsql(self, columns, loadfile, intotable=None, fieldterminated=','): | |
class MysqlDB(DBCommon, DBFileExec): | ||
_instance_lock = threading.Lock() | ||
|
||
def __init__(self, host, user, password, database, port=3306, charset="utf8", safe_rule=True): | ||
def __init__(self, host, user, password, database, port=3306, charset="utf8", safe_rule=True, isdoris=False): | ||
self.host = host | ||
self.port = port | ||
self.user = user | ||
self.password = password | ||
self.database = database | ||
self.charset = charset | ||
self.isdoris = isdoris | ||
super(MysqlDB, self).__init__() | ||
self.auto_rules = AUTO_RULES if safe_rule else None | ||
|
||
|
@@ -115,7 +121,8 @@ def get_instance(cls, *args, **kwargs): | |
return MysqlDB._instance | ||
|
||
def get_conn(self): | ||
conn = pymysql.connect(database=self.database, user=self.user, password=self.password, host=self.host, port=self.port, charset=self.charset) | ||
conn = pymysql.connect(database=self.database, user=self.user, password=self.password, | ||
host=self.host, port=self.port, charset=self.charset) | ||
if not conn: | ||
self.get_conn() | ||
return conn | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# @Author: chunyang.xu | ||
# @Email: [email protected] | ||
# @Date: 2020-11-30 16:28:21 | ||
# @Last Modified time: 2021-08-09 13:46:27 | ||
# @Last Modified time: 2021-08-25 14:46:00 | ||
# @github: https://github.com/longfengpili | ||
|
||
# !/usr/bin/env python3 | ||
|
@@ -53,6 +53,9 @@ def __init__(self, *columns): | |
def __repr__(self): | ||
return f"{[column for column in self.columns]}" | ||
|
||
def __getitem__(self, key): | ||
return self.columns[key] | ||
|
||
@property | ||
def func_cols(self): | ||
func_cols = [col for col in self.columns if col.func] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# @Author: chunyang.xu | ||
# @Email: [email protected] | ||
# @Date: 2020-06-09 16:46:54 | ||
# @Last Modified time: 2021-08-11 11:13:22 | ||
# @Last Modified time: 2021-08-25 14:36:33 | ||
# @github: https://github.com/longfengpili | ||
|
||
# !/usr/bin/env python3 | ||
|
@@ -12,7 +12,7 @@ | |
import shutil | ||
import setuptools | ||
|
||
VERSION = '0.0.64' | ||
VERSION = '0.0.65' | ||
PROJECT_NAME = 'pydbapi' | ||
|
||
with open('README.md', 'r', encoding='utf-8') as f: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters