def convert_sql_to_xml(filename, id): config = {"host": "localhost", "port": 3306, "user": "******", "passwd": "vistrailspwd", "db": "vistrails"} try: dbConnection = io.open_db_connection(config) vistrail = io.open_vistrail_from_db(dbConnection, id) io.setDBParameters(vistrail, config) io.save_vistrail_to_xml(vistrail, filename) io.close_db_connection(dbConnection) except MySQLdb.Error, e: print e
def convert_sql_to_xml(filename, id): config = {'host': 'vistrails.sci.utah.edu', 'port': 3306, 'user': '******', 'passwd': '8edLj4', 'db': 'vistrails'} try: db_connection = io.open_db_connection(config) vistrail = io.open_vistrail_from_db(db_connection, id) io.save_vistrail_to_xml(vistrail, filename) io.close_db_connection(db_connection) except MySQLdb.Error, e: print e
def convert_sql_to_xml(filename, id): config = {'host': 'localhost', 'port': 3306, 'user': '******', 'passwd': 'vistrailspwd', 'db': 'vistrails'} try: dbConnection = io.open_db_connection(config) vistrail = io.open_vistrail_from_db(dbConnection, id) io.setDBParameters(vistrail, config) io.save_vistrail_to_xml(vistrail, filename) io.close_db_connection(dbConnection) except MySQLdb.Error, e: print e
def convert_sql_to_xml(filename, id): config = { 'host': 'localhost', 'port': 3306, 'user': '******', 'passwd': 'vistrailspwd', 'db': 'vistrails' } try: dbConnection = io.open_db_connection(config) vistrail = io.open_vistrail_from_db(dbConnection, id) io.setDBParameters(vistrail, config) io.save_vistrail_to_xml(vistrail, filename) io.close_db_connection(dbConnection) except MySQLdb.Error, e: print e
def convert_xml_to_sql(filename): config = {"host": "localhost", "port": 3306, "user": "******", "passwd": "vistrailspwd", "db": "vistrails"} try: vistrail = io.open_vistrail_from_xml(filename) dbConnection = io.open_db_connection(config) print dbConnection.get_server_info() print dbConnection.get_host_info() print dbConnection.stat() print str(dbConnection) io.save_vistrail_to_db(vistrail, dbConnection) io.close_db_connection(dbConnection) print "db_id: ", vistrail.db_id except Exception, e: print e
def convert_xml_to_sql(filename): config = {'host': 'localhost', 'port': 3306, 'user': '******', 'passwd': 'vistrailspwd', 'db': 'vistrails'} try: vistrail = io.open_vistrail_from_xml(filename) dbConnection = io.open_db_connection(config) print dbConnection.get_server_info() print dbConnection.get_host_info() print dbConnection.stat() print str(dbConnection) io.save_vistrail_to_db(vistrail, dbConnection) io.close_db_connection(dbConnection) print 'db_id: ', vistrail.db_id except Exception, e: print e
def delete_from_db(config, obj_type, obj_id): db_connection = io.open_db_connection(config) io.delete_entity_from_db(db_connection, obj_type, obj_id) io.close_db_connection(db_connection)
continue io.save_vistrail_bundle_to_zip_xml(res, vt_name, local_tmp_dir) # drop the old database # recreate with the new version of the specs io.setup_db_tables(db_connection, None, old_version) # add the new data back for filename in filenames: (res, _) = io.open_vistrail_bundle_from_zip_xml(filename) try: io.save_vistrail_bundle_to_db(res, db_connection, 'with_ids') except Exception, e: import traceback print filename, e, traceback.format_exc() io.close_db_connection(db_connection) if __name__ == '__main__': import vistrails.core.application more_options = {'v:': ('set new schema version', False, 'version'), 'd:': ('set temporary directory', False, 'directory'), 'e:': ('restore from directory', False, 'restore') } config, options = parse_db_cmd_line(sys.argv, more_options) new_version = None if options['v']: new_version = options['v'] vistrails.core.application.init()
if 0 == offset: select_part = 'SELECT count(0)' command = ' '.join([select_part,from_part,where_part]) +';' #print command try: c = db.cursor() c.execute(command) res = c.fetchall() result= (result, res[0][0]) c.close() except get_db_lib().Error, e: msg = "Couldn't perform query on db (%d : %s)" % \ (e.args[0], e.args[1]) raise VistrailsDBException(msg) close_db_connection(db) return result def runLogQuery(config, vistrail=None, version=None, fromTime=None, toTime=None, user=None, completed=None, offset=0, limit=100, modules=[], thumbs=None): # returns list of workflow executions: # (vistrail name, vistrail id, log id, workflow id, workflow name, # execution id, start time, end time, user, completed, thumb) result = [] db = open_db_connection(config) select_part = \ """SELECT DISTINCT v.name, v.id, w.entity_id, w.parent_version, a1.value, w.id, w.ts_start, w.ts_end, w.user, w.completed""" from_part = \