def __init__(self, fs, options={}): sqlFileDb.__init__(self, fs, options) self.options = options self.connect() self.sqlLock = Lock() prefix = options.get( "prefix", fs.config["host"].replace(":","_").replace(".","_") ) self.t_files = prefix + "_files" self.t_nodes = prefix + "_nodes" self.t_files_nodes = prefix + "_files_nodes" from warnings import filterwarnings, resetwarnings filterwarnings('ignore', category=MySQLdb.Warning ) self.execute("""CREATE TABLE IF NOT EXISTS `""" + self.t_files + """` ( `id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `size` int(11) DEFAULT NULL, `t` timestamp NULL DEFAULT NULL, `n` float DEFAULT NULL, `kn` float DEFAULT NULL, `nuked` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `filename` (`filename`), KEY `nuked` (`nuked`) );""") self.execute("""CREATE TABLE IF NOT EXISTS `""" + self.t_files_nodes + """` ( `file_id` int(11) NOT NULL DEFAULT '0', `node_id` int(11) NOT NULL, PRIMARY KEY (`file_id`,`node_id`), KEY `node` (`node_id`) );""") self.execute("""CREATE TABLE IF NOT EXISTS `""" + self.t_nodes + """` ( `id` int(11) NOT NULL AUTO_INCREMENT, `address` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `address` (`address`) );""") resetwarnings()
def __init__(self, fs, options={}): sqlFileDb.__init__(self, fs, options) self.options = options self.connect() self.sqlLock = Lock() prefix = options.get( "prefix", fs.config["host"].replace(":", "_").replace(".", "_")) self.t_files = prefix + "_files" self.t_nodes = prefix + "_nodes" self.t_files_nodes = prefix + "_files_nodes" from warnings import filterwarnings, resetwarnings filterwarnings('ignore', category=MySQLdb.Warning) self.execute("""CREATE TABLE IF NOT EXISTS `""" + self.t_files + """` ( `id` int(11) NOT NULL AUTO_INCREMENT, `filename` varchar(255) CHARACTER SET utf8 DEFAULT NULL, `size` int(11) DEFAULT NULL, `t` timestamp NULL DEFAULT NULL, `n` float DEFAULT NULL, `kn` float DEFAULT NULL, `nuked` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `filename` (`filename`), KEY `nuked` (`nuked`) );""") self.execute("""CREATE TABLE IF NOT EXISTS `""" + self.t_files_nodes + """` ( `file_id` int(11) NOT NULL DEFAULT '0', `node_id` int(11) NOT NULL, PRIMARY KEY (`file_id`,`node_id`), KEY `node` (`node_id`) );""") self.execute("""CREATE TABLE IF NOT EXISTS `""" + self.t_nodes + """` ( `id` int(11) NOT NULL AUTO_INCREMENT, `address` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `address` (`address`) );""") resetwarnings()
def __init__(self, fs, options={}): sqlFileDb.__init__(self, fs, options) self.options = options self.sqlLock = Lock() self.connect() self.t_files = "files" self.t_nodes = "nodes" self.t_files_nodes = "files_nodes" self.execute("""CREATE TABLE IF NOT EXISTS """ + self.t_files + """ ( id INTEGER PRIMARY KEY, filename TEXT, size INTEGER, t INTEGER, n REAL, kn REAL, nuked INTEGER );""") self.execute("""CREATE UNIQUE INDEX IF NOT EXISTS i_filename ON """ + \ self.t_files + """(filename)""") self.execute("""CREATE INDEX IF NOT EXISTS i_nuked ON """ + \ self.t_files + """(nuked)""") self.execute("""CREATE INDEX IF NOT EXISTS i_kn ON """ + \ self.t_files + """(kn)""") self.execute("""CREATE TABLE IF NOT EXISTS """ + self.t_files_nodes + \ """ (file_id INTEGER, node_id INTEGER, PRIMARY KEY (file_id,node_id) );""") self.execute("""CREATE INDEX IF NOT EXISTS i_node ON """ + \ self.t_files_nodes + """(node_id)""") self.execute("""CREATE TABLE IF NOT EXISTS """ + self.t_nodes + """ ( id INTEGER PRIMARY KEY, address TEXT );""") self.execute("""CREATE UNIQUE INDEX IF NOT EXISTS i_address ON """ + \ self.t_nodes + """(address)""")