Beispiel #1
0
def create_record_table(table):
    create_sql = '''CREATE TABLE IF NOT EXISTS `%s` (
                      `%s` int(11) NOT NULL AUTO_INCREMENT,
                      `%s` varchar(255) NOT NULL,
                      `%s` int(11) NOT NULL,
                      `%s` varchar(255) NOT NULL,
                      `%s` varchar(255) NOT NULL,
                      PRIMARY KEY (`%s`)
                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;''' % \
                    (table, record.KEY_RECORD_ID, record.KEY_RECORD_URL,
                     record.KEY_STATUS, record.KEY_STORE_PATH, record.KEY_EXTRA, 
                     record.KEY_RECORD_ID)
    _pool.execute(create_sql)
Beispiel #2
0
def delete(table, where_clause = ''):
    sql = '''DELETE FROM %s %s;''' % (table, where_clause)
    return _pool.execute(sql)
Beispiel #3
0
def update(table, record):
    sql = '''UPDATE %s SET %s='%s', %s=%s, %s='%s', %s='%s' WHERE %s=%s;''' % (
            table, KEY_RECORD_URL, record.record_url, KEY_STATUS, record.status,
            KEY_STORE_PATH, record.store_path, KEY_EXTRA, record.extra, 
            KEY_RECORD_ID, record.record_id)
    return _pool.execute(sql)
Beispiel #4
0
def insert(table, record):
    sql = '''INSERT INTO %s(%s, %s, %s, %s) 
             VALUES('%s', %s, '%s', '%s');''' % (table, 
            KEY_RECORD_URL, KEY_STATUS, KEY_STORE_PATH, KEY_EXTRA,
            record.record_url, record.status, record.store_path, record.extra)
    return _pool.execute(sql)