示例#1
0
def create(exec_cmd=run):
    require('database')
    db = env.database

    exec_cmd('echo "CREATE DATABASE \`{db_name}\` CHARACTER SET utf8;"'
             '|mysql --batch'
             ' --user={user}'
             ' --password={password}'
             ' --host={host}'
             ' --port={port}'
             ' --default-character-set=utf8'.format(
                 db_name=shell_escape(db.name),
                 user=shell_escape(db.user),
                 password=shell_escape(db.password),
                 host=db.host,
                 port=db.port,
             ),
             shell=False)
    """
示例#2
0
文件: mysql.py 项目: ceasaro/jeslee
def create(exec_cmd=run):
    require('database')
    db = env.database
    
    exec_cmd('echo "CREATE DATABASE \`{db_name}\` CHARACTER SET utf8;"'
             '|mysql --batch'
             ' --user={user}'
             ' --password={password}'
             ' --host={host}'
             ' --port={port}'
             ' --default-character-set=utf8'.format(
                      db_name=shell_escape(db.name),
                      user=shell_escape(db.user),
                      password=shell_escape(db.password),
                      host=db.host,
                      port=db.port,
              ),
             shell=False
    )
    """
示例#3
0
def backup(exec_cmd=run, outfile='None'):
    require('database')
    db = env.database
    if not outfile:
        outfile = '{}-dump.sql.bz2'.format(db.name)

    exec_cmd('mysqldump'
             ' --user={user}'
             ' --password={password}'
             ' --host={host}'
             ' --port={port}'
             ' {db_name}'
             ' | bzip2 --best '
             ' > {outfile}'.format(db_name=shell_escape(db.name),
                                   user=shell_escape(db.user),
                                   password=shell_escape(db.password),
                                   host=db.host,
                                   port=db.port,
                                   outfile=outfile))
    env.database_backup_remote_file = outfile
示例#4
0
文件: mysql.py 项目: ceasaro/jeslee
def backup(exec_cmd=run, outfile='None'):
    require('database')
    db = env.database
    if not outfile:
        outfile = '{}-dump.sql.bz2'.format(db.name)

    exec_cmd('mysqldump'
          ' --user={user}'
          ' --password={password}'
          ' --host={host}'
          ' --port={port}'
          ' {db_name}' 
          ' | bzip2 --best '
          ' > {outfile}'.format(
                      db_name=shell_escape(db.name),
                      user=shell_escape(db.user),
                      password=shell_escape(db.password),
                      host=db.host,
                      port=db.port,
                      outfile=outfile
                      )
    )
    env.database_backup_remote_file = outfile