sync同步mysql结构如下
##同步数据
class sync_sql(object):
"""
Main entrance to ODPS.
"""
def __init__(self):
"""
"""
self.conn = conn
print(self.conn)
self._db_cur = self.conn.cursor()
#pass
def get_table(self, name=None):
"""
Get table by given name.
"""
conn = self.conn
cursor = conn.cursor()
cursor.execute("show tables;")
tables = cursor.fetchall()
print(tables)
pass
return tables
def exist_table(self, name, project=None):
"""
If the table with given name exists or not.
:param name: table name
:param project: project name, if not provided, will be the default project
:return: True if table exists or False
:rtype: bool
"""
self._db_cur.execute("show tables;")
table = [item.values() for item in data if name in item.values()]
return len(table)
pass
def create_table(self, name, schema, if_not_exists=False, **kw):
"""
Create an table by given schema and other optional parameters
"""
pass
def delete_table(self, name, if_exists=False, async_=False, **kw):
"""
Delete the table with given name
"""
pass
def read_table(self, name, limit=None,**kw):
"""
Read table's records.
"""
pass
def write_table(self, name, *block_records, **kw):
"""
Write records into given table.
"""
pass
def execute_sql(self, sql, **kwargs):
"""
Run a given SQL statement and block until the SQL executed successfully.
:param sql: SQL statement
:type sql: str
"""
pass
参考:
"""
Python Create a Table in MySQL from Dictionary - Softhints
python - Create table from dictionary data in a safe way - Stack Overflow
"""