Exemple #1
0
def create_database(name, user, password):
    control = monetdb.control.Control(MONETDB_HOST, MONETDB_PORT, MONETDB_PASSPHRASE)
    control.create(name)
    control.release(name)

    con = monetdb.sql.connect(username='******', password='******',
                              hostname=MONETDB_HOST, port=MONETDB_PORT,
                              database=name)
    cur = con.cursor()

    params = {
        'username': user,
        'password': password,
        'database': name,
    }
    cur.execute(auth_query % params)
Exemple #2
0
def create_database(name, user, password):
    control = monetdb.control.Control(MONETDB_HOST, MONETDB_PORT,
                                      MONETDB_PASSPHRASE)
    control.create(name)
    control.release(name)

    con = monetdb.sql.connect(username='******',
                              password='******',
                              hostname=MONETDB_HOST,
                              port=MONETDB_PORT,
                              database=name)
    cur = con.cursor()

    params = {
        'username': user,
        'password': password,
        'database': name,
    }
    cur.execute(auth_query % params)
Exemple #3
0
        control = monetdb.control.Control(dbconfig['host'], dbconfig['port'],
                                          dbconfig['passphrase'])

        database = dbconfig['database']
        print("stopping %s" % database)
        try:
            control.stop(database)
        except monetdb.sql.OperationalError, e:
            print("database not running")
        print "destroying %s" % database
        try:
            control.destroy(database)
        except monetdb.sql.OperationalError, e:
            print("can't destroy database: %s" % str(e))

        control.create(database)
        control.release(database)
        control.start(database)

        con = monetdb.sql.connect(username='******', password='******',
                                  hostname=dbconfig['host'], port=dbconfig['port'],
                                  database=dbconfig['database'])
        cur = con.cursor()
        cur.execute(auth_query % params)
        con.commit()
        con.close()

    elif dbconfig['engine'] == 'postgresql':
        print "destroying database %(database)s on %(host)s..." % params
        call('dropdb -h %(host)s -U %(username)s %(database)s' % params,
             shell=True)