Example #1
0
def loadTables(myhost, myport, myuser, mypassword, databaseName):
    wkdir = localsettings.determine_path()
    f = open(os.path.join(wkdir,"resources","demodump.sql"),"r")
    dumpString = f.read()
    f.close()
    print myhost, myport, myuser, databaseName, mypassword
    db = MySQLdb.connect(host = myhost, port = myport,
    user = myuser, db = databaseName, passwd = mypassword)

    cursor = db.cursor()
    cursor.execute(dumpString)
    cursor.close()
    db.commit()
    db.close()
    return True
Example #2
0
def loadTables(myhost, myport, myuser, mypassword, databaseName):
    wkdir = localsettings.determine_path()
    f = open(os.path.join(wkdir, "resources", "demodump.sql"), "r")
    dumpString = f.read()
    f.close()
    print myhost, myport, myuser, databaseName, mypassword
    db = MySQLdb.connect(host=myhost,
                         port=myport,
                         user=myuser,
                         db=databaseName,
                         passwd=mypassword)

    cursor = db.cursor()
    cursor.execute(dumpString)
    cursor.close()
    db.commit()
    db.close()
    return True
Example #3
0
def create_tables(host_, port_, user_, pass_wd, db_name):
    try:
        wkdir = localsettings.determine_path()
        f = open(os.path.join(wkdir, "resources", "schema.sql"), "r")
        sql_statements = f.read()
        f.close()

        db = MySQLdb.connect(host=host_,
                             port=port_,
                             user=user_,
                             db=db_name,
                             passwd=pass_wd)

        cursor = db.cursor()
        cursor.execute(sql_statements)
        cursor.close()
        db.commit()
        db.close()
        return True
    except:
        LOGGER.exception("error creating database tables")
Example #4
0
def create_tables(host_, port_, user_, pass_wd, db_name):
    try:
        wkdir = localsettings.determine_path()
        f = open(os.path.join(wkdir, "resources", "schema.sql"), "r")
        sql_statements = f.read()
        f.close()

        db = MySQLdb.connect(host=host_,
                             port=port_,
                             user=user_,
                             db=db_name,
                             passwd=pass_wd)

        cursor = db.cursor()
        cursor.execute(sql_statements)
        cursor.close()
        db.commit()
        db.close()
        return True
    except:
        LOGGER.exception("error creating database tables")