Esempio n. 1
0
def create_table(name,data):
    tmp = []
    for v in data:
        tmp.append('%s varchar(200)'%v['name'])
    sql = 'create table %s (id int not null auto_increment primary key,%s)' % (name,','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)
Esempio n. 2
0
def create_table(name,data):
    tmp = []
    for v in data:
        tmp.append('%s varchar(200)'%v['name'])
    sql = 'create table %s (id int not null auto_increment primary key,%s) ENGINE=InnoDB DEFAULT CHARSET=utf8' % (name,','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)
Esempio n. 3
0
def create_table(name, data):
    tmp = []
    for v in data:
        tmp.append('%s varchar(200)' % v['name'])
    sql = 'create table %s (id int not null auto_increment primary key,%s) type=myisam default charset utf8' % (
        name, ','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)
Esempio n. 4
0
def del_table(name):
    sql = 'drop table if exists '+name
    print sql
    db.execute(sql)
Esempio n. 5
0
    print sql
    db.execute(sql)
def create_table(name,data):
    tmp = []
    for v in data:
        tmp.append('%s varchar(200)'%v['name'])
    sql = 'create table %s (id int not null auto_increment primary key,%s) ENGINE=InnoDB DEFAULT CHARSET=utf8' % (name,','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)
def init_database(config):

    for c in config:
        name = c['name']
        del_table(name)
        create_table(name,c['data'])

if __name__ == '__main__':
    config = []
    for page in page_config['menu']:
        if 'sub' in page:
            for s in page['sub']:
                config.append(s)
        else:
            config.append(page)
    print config
    if len(sys.argv)>1 and sys.argv[1]=='init':
        init_database(config)
        db.execute('insert into user (username,password) values ("51reboot","51reboot")')
    gen_config(config)
Esempio n. 6
0
def del_table(name):
    sql = 'drop table if exists '+name
    print sql
    db.execute(sql)
Esempio n. 7
0
    sql = 'drop table if exists '+name
    print sql
    db.execute(sql)
def create_table(name,data):
    tmp = []
    for v in data:
        tmp.append('%s varchar(200)'%v['name'])
    sql = 'create table %s (id int not null auto_increment primary key,%s)' % (name,','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)
def init_database(config):

    for c in config:
        name = c['name']
        del_table(name)
        create_table(name,c['data'])

if __name__ == '__main__':
    config = []
    for page in page_config['menu']:
        if 'sub' in page:
            for s in page['sub']:
                config.append(s)
        else:
            config.append(page)
    print config
    if len(sys.argv)>1 and sys.argv[1]=='init':
        init_database(config)
        db.execute('insert into user (username,password) values ("admin","admin")')
    gen_config(config)
Esempio n. 8
0
    sql = 'drop table if exists '+name
    print sql
    db.execute(sql)
def create_table(name,data):
    tmp = []
    for v in data:
        tmp.append('%s varchar(200)'%v['name'])
    sql = 'create table %s (id int not null auto_increment primary key,%s) type=myisam default charset utf8' % (name,','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)
def init_database(config):

    for c in config:
        name = c['name']
        del_table(name)
        create_table(name,c['data'])

if __name__ == '__main__':
    config = []
    for page in page_config['menu']:
        if 'sub' in page:
            for s in page['sub']:
                config.append(s)
        else:
            config.append(page)
    print config
    if len(sys.argv)>1 and sys.argv[1]=='init':
        init_database(config)
        db.execute('insert into user (username,password) values ("51reboot","51reboot")')
    gen_config(config)
Esempio n. 9
0
    sql = 'create table %s (id int not null auto_increment primary key,%s)' % (
        name, ','.join(tmp))
    print sql
    db.execute(sql)
    print 'table %s is created' % (name)


def init_database(config):

    for c in config:
        name = c['name']
        del_table(name)
        create_table(name, c['data'])


if __name__ == '__main__':
    config = []
    for page in page_config['menu']:
        if 'sub' in page:
            for s in page['sub']:
                config.append(s)
        else:
            config.append(page)
    print config
    if len(sys.argv) > 1 and sys.argv[1] == 'init':
        init_database(config)
        db.execute(
            'insert into user (username,password) values ("qingteng","qingteng@qt2016")'
        )
    gen_config(config)