Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

howto to create mysql database from fabric dynamically

Tags:

sql

mysql

fabric

Is it possible to create mysql database from fabric dynamically.

This seems like it gets stuck at the password prompt

run('mysql -u %s -p %s -h %s  ' % (env.mysqluser, env.mysqlpassword, env.mysqlhost), pty=True)
run('CREATE DATABASE %s; ' % (dataname), pty=True)
run('exit', pty=True)
like image 392
bocca Avatar asked Dec 11 '09 09:12

bocca


2 Answers

There's a better way of doing this using mysqladmin:

run('mysqladmin -u %s -p%s create %s' % (user, password, dbname))
like image 129
Jeffrey McManus Avatar answered Nov 13 '22 16:11

Jeffrey McManus


Try instead

run('echo "CREATE DATABASE %s;"|mysql --batch --user=%s --password=%s --host=%s' % (dataname, env.mysqluser, env.mysqlpassword, env.mysqlhost), pty=True)
like image 24
Conspicuous Compiler Avatar answered Nov 13 '22 17:11

Conspicuous Compiler