Beispiel #1
0
 def dropDB(self, dbName):
     if not dbName in self.listDatabases():
         return
     self.disconnectAll(dbName)
     cmd = '%s -p %s -h %s %s' % (self.cmd('dropdb'), self.port, self.host,
                                  dbName)
     util.system(cmd)
Beispiel #2
0
 def dump(self, dbName, path):
     assert self.isRunning()
     path = os.path.abspath(path)
     cmd = '%s -p %s %s > %s' % (self.cmd('pg_dump'), self.port, dbName,
                                 path)
     print >> sys.stderr, "DUMP: %r" % cmd
     util.system(cmd)
Beispiel #3
0
 def dropDB(self, dbName):
     if not dbName in self.listDatabases():
         return
     self.disconnectAll(dbName)
     cmd = '%s -p %s -h %s %s' % (self.cmd('dropdb'),
                                  self.port, self.host, dbName)
     util.system(cmd)
Beispiel #4
0
 def initDB(self):
     if not os.path.exists(self.dbDir):
         os.makedirs(self.dbDir)
     cmd = "%s --ldata=%s" % (self.cmd('mysql_install_db'), self.dbDir)
     t = time.time()
     util.system(cmd)
     print >> sys.stderr, "INITDB: %r in %s secs" % (self.dbDir,
                                                     time.time() - t)
Beispiel #5
0
 def dump(self, dbName, path):
     assert self.isRunning()
     path = os.path.abspath(path)
     cmd = '%s -p %s %s > %s' % (self.cmd('pg_dump'),
                                 self.port, dbName,
                                 path)
     print >> sys.stderr, "DUMP: %r" % cmd
     util.system(cmd)
Beispiel #6
0
 def initDB(self):
     #         if not os.path.exists(self.dbDir):
     #             os.makedirs(self.dbDir)
     cmd = '%s -A trust -D %s >/dev/null' % (self.cmd('initdb'), self.dbDir)
     t = time.time()
     util.system(cmd)
     print >> sys.stderr, "INITDB: %r in %s secs" % (self.dbDir,
                                                     time.time() - t)
Beispiel #7
0
 def initDB(self):
     if not os.path.exists(self.dbDir):
         os.makedirs(self.dbDir)
     cmd = "%s --ldata=%s" % (self.cmd('mysql_install_db'), self.dbDir)
     t = time.time()
     util.system(cmd)
     print >> sys.stderr, "INITDB: %r in %s secs" % (self.dbDir,
                                                     time.time()-t)
Beispiel #8
0
    def initDB(self):
#         if not os.path.exists(self.dbDir):
#             os.makedirs(self.dbDir)
        cmd = '%s -A trust -D %s >/dev/null' % (self.cmd('initdb'),
                                                self.dbDir)
        t = time.time()
        util.system(cmd)
        print >> sys.stderr, "INITDB: %r in %s secs" % (self.dbDir,
                                                        time.time()-t)
Beispiel #9
0
 def runScripts(self, dbName, scripts):
     """runs sql scripts from given paths"""
     for script in scripts:
         script = self.resolveScriptPath(script)
         if self.verbose:
             output = ''
         else:
             output = '>/dev/null 2>&1'
         util.system('%s -q -f %s %s %s' % (
                                 self.psql, script, dbName, output))
Beispiel #10
0
 def runScripts(self, dbName, scripts):
     """runs sql scripts from given paths"""
     for script in scripts:
         script = self.resolveScriptPath(script)
         if self.verbose:
             output = ''
         else:
             output = '>/dev/null 2>&1'
         util.system('%s -q -f %s %s %s' %
                     (self.psql, script, dbName, output))
Beispiel #11
0
 def start(self):
     daemon_path = self.mysqld_path()
     if not daemon_path:
         raise IOError, "mysqld was not found. Is a MySQL server installed?"
     if self.defaults_file:
         defaults = '--defaults-file="%s"' % self.defaults_file
     else:
         defaults = '--no-defaults'
     cmd = "%s %s --datadir=%s --port=%i --pid-file=%s/mysql.pid --socket=%s/mysql.sock & > /dev/null 2>&1 " % (
                            daemon_path, defaults, self.dbDir, self.port, self.dbDir, self.dbDir)
     util.system(cmd)
     while not self.isRunning():
         time.sleep(0.1)
Beispiel #12
0
 def start(self):
     daemon_path = self.mysqld_path()
     if not daemon_path:
         raise IOError, "mysqld was not found. Is a MySQL server installed?"
     if self.defaults_file:
         defaults = '--defaults-file="%s"' % self.defaults_file
     else:
         defaults = '--no-defaults'
     cmd = "%s %s --datadir=%s --port=%i --pid-file=%s/mysql.pid --socket=%s/mysql.sock & > /dev/null 2>&1 " % (
         daemon_path, defaults, self.dbDir, self.port, self.dbDir,
         self.dbDir)
     util.system(cmd)
     while not self.isRunning():
         time.sleep(0.1)
Beispiel #13
0
 def createDB(self, dbName):
     cmd = "%s -e 'CREATE DATABASE %s'" % (self.mysql, dbName)
     util.system(cmd)
Beispiel #14
0
 def stop(self):
     cmd = "%s shutdown > /dev/null 2>&1" % self.mysqladmin
     util.system(cmd)
     while self.isRunning():
         time.sleep(0.3)
Beispiel #15
0
 def createDB(self, dbName):
     cmd = '%s -p %s -h %s %s' % (self.cmd('createdb'), self.port,
                                  self.host, dbName)
     util.system(cmd)
Beispiel #16
0
 def dump(self, dbName, path):
     assert self.isRunning()
     path = os.path.abspath(path)
     cmd = "%s -r %s %s" % (self.mysqldump, path, dbName)
     print >> sys.stderr, "DUMP: %r" % cmd
     util.system(cmd)
Beispiel #17
0
 def ctl(self, arg):
     cmd = '%s -l "%s" -D %s %s' % (self.cmd('pg_ctl'), self.pgCtlLog,
                                    self.dbDir, arg)
     util.system(cmd)
Beispiel #18
0
 def createDB(self, dbName):
     cmd = "%s -e 'CREATE DATABASE %s'" % (self.mysql, dbName)
     util.system(cmd)
Beispiel #19
0
 def dropDB(self, dbName):
     if not dbName in self.listDatabases():
         return
     cmd = "%s -e 'DROP DATABASE %s'" % (self.mysql, dbName)
     util.system(cmd)
Beispiel #20
0
 def runScripts(self, dbName, scripts):
     """runs sql scripts from given paths"""
     for script in scripts:
         script = self.resolveScriptPath(script)
         cmd = "%s %s < %s" % (self.mysql, dbName, script)
         util.system(cmd)
Beispiel #21
0
 def dump(self, dbName, path):
     assert self.isRunning()
     path = os.path.abspath(path)
     cmd = "%s -r %s %s" % (self.mysqldump, path, dbName)
     print >> sys.stderr, "DUMP: %r" % cmd
     util.system(cmd)
Beispiel #22
0
 def stop(self):
     cmd = "%s shutdown > /dev/null 2>&1" % self.mysqladmin
     util.system(cmd)
     while self.isRunning():
         time.sleep(0.3)
Beispiel #23
0
 def ctl(self, arg):
     cmd = '%s -l "%s" -D %s %s' % (self.cmd('pg_ctl'),
                                    self.pgCtlLog,
                                    self.dbDir, arg)
     util.system(cmd)
Beispiel #24
0
 def dropDB(self, dbName):
     if not dbName in self.listDatabases():
         return
     cmd = "%s -e 'DROP DATABASE %s'" % (self.mysql, dbName)
     util.system(cmd)
Beispiel #25
0
 def createDB(self, dbName):
     cmd = '%s -p %s -h %s %s' % (self.cmd('createdb'),
                                  self.port, self.host, dbName)
     util.system(cmd)
Beispiel #26
0
 def runScripts(self, dbName, scripts):
     """runs sql scripts from given paths"""
     for script in scripts:
         script = self.resolveScriptPath(script)
         cmd = "%s %s < %s" % (self.mysql, dbName, script)
         util.system(cmd)