示例#1
0
文件: tests.py 项目: bourivouh/djonet
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)
示例#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)
示例#3
0
文件: populate.py 项目: hughbg/tkp
                                          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)
        print "creating database %(database)s on %(host)s..." % params