- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Modules/Macros/STUDBConn/DBConn.py

    00001 """
    00002 * Copyright (c) 2009 Stanford University, School of Medicine All rights reserved.
    00003 *
    00004 * STANFORD ACADEMIC SOFTWARE LICENSE AGREEMENT
    00005 * FOR AngioLocalize SOURCE CODE:
    00006 *
    00007 * 1.    This is a legal agreement between you, RECIPIENT, and STANFORD UNIVERSITY.
    00008 *       By accepting, receiving, and using AngioLocalize.including any accompanying information, materials or
    00009 *       manuals (Program), you are agreeing to be bound by the terms of this Agreement.
    00010 *       If you do not agree to the terms of this Agreement, promptly return the Program to the STANFORD.
    00011
    00012 * 2.    STANFORD grants to RECIPIENT a royalty-free, nonexclusive, and nontransferable license to use the Program
    00013 *       and accompanying source code furnished hereunder, upon the terms and conditions set out below.
    00014 *       documentation and/or other materials provided with the distribution.
    00015 * 3.    RECIPIENT acknowledges that the Program is a research tool still in the development stage and that
    00016 *       it is being supplied as is, without any accompanying services, support or improvements from STANFORD.
    00017 * 4.    RECIPIENT agrees to use the Program solely for internal non-commercial purposes.
    00018 * 5.    RECIPIENT may create derivatives and further transfer the Program under the following terms and conditions:
    00019 *        A) Recipient agrees to not commercially exploit the Program and agrees all uses will be for non-commercial purposes; and,
    00020 *        B) Recipient may not mark any derivatives with the title of Program and may not to use iPad mark for any derivatives; and,
    00021 *        C) Recipient agrees to mark and acknowledge all derivatives as follows: "This is a derivative work based on AngioLocalize:
    00022 *           Frameless AVM localization with 2D Digital Subtraction Angiography (DSA) and 3D Rotational Angiography (DRA) Images developed
    00023 *           by Dimitre Hristov, Lina Liu.
    00024 *        D) Recipient agrees to make all improvements, enhancements and derivatives available under
    00025 *           similar terms and conditions to the research community.
    00026 * 6.    RECIPIENT warrants that RECIPIENT will not remove or export any part of the software or Program from the United
    00027 *       States except in full compliance with all United States and other applicable laws and regulations.
    00028 * 7.    RECIPIENT will use the Program in compliance with all applicable laws, policies and regulations including, but not
    00029 *       limited to, any approvals, informed consent and patient confidentiality principles.
    00030 * 8.    RECIPIENT will indemnify, hold harmless, and defend Stanford against any claim of any kind arising out of or
    00031 *       related to the exercise of any rights granted under this Agreement or the breach of this Agreement by RECIPIENT.
    00032 * 9.    Title and copyright to the Program and any associated documentation shall at all times remain with STANFORD,
    00033 *       and RECIPIENT agrees to preserve same.
    00034 """
    00035 #----------------------------------------------------------------------------------
    00036 #! Macro module DBConn
    00037 #/*!
    00038 # \file    DBConn.py
    00039 # \author  LinaLiu
    00040 # \date    2009-12-09
    00041 #
    00042 # DBConn handles db connection/disconnection and query
    00043 #*/
    00044 #----------------------------------------------------------------------------------
    00045
    00046 from mevis import *
    00047
    00048 ## Global variable
    00049 db = None;
    00050
    00051 ## open the DB connection with certain username and password
    00052 ## the username and password has to be "root" and "1234"
    00053 def open():
    00054   global db;
    00055   db = MLAB.addSqlDatabase("POSTGRES");
    00056   db.setUserName("postgres");
    00057   db.setPassword("1234");
    00058   db.setDatabaseName("AngioLocalize");
    00059   db.setHostName("localhost");
    00060   db.setPort(5432);
    00061   return db.open();
    00062
    00063 ## The function submit a query which is indicated in Statement fields in the module
    00064 ## If the query fails, -1 will return as result, otherwise, the query result will be returned.
    00065 def sendQuery():
    00066   global db;
    00067   if (db == None):
    00068     open();
    00069   result = db.query(ctx.field("Statement").value);
    00070   if (result == -1):
    00071     MLAB.log("Error:" + db.lastError()["message"] + ctx.field("Statement").value);
    00072     return -1;
    00073   else:
    00074     return result;
    00075
    00076 ## close the DB connection and put this event in log
    00077 def close():
    00078   global db;
    00079   if (db):
    00080     db.close();
    00081     MLAB.removeSqlDatabase(db);
    00082   db = None;
    00083 #//# MeVis signature v1
    00084 #//# key: MFowDQYJKoZIhvcNAQEBBQADSQAwRgJBANEfsmYse2e1dRhkQ9AQbreCq9uxwzWLoGom13MNYmyfwoJqQOEXljLFAgw2eEjaT12G4CdqKWhRxh9ANP6n7GMCARE=:VI/mB8bT4u+mRtf/ru8yUQi8BzpaS3UeL2x62YxsUYnVqCWuLrVNLiukIIjnJMKQXlc8ezmgOIcVAV7pgvgKpQ==
    00085 #//# owner: MeVis
    00086 #//# date: 2009-06-10T04:12:25
    00087 #//# hash: vHSfj+Qt8xrIkDVP4W0Rep0YH6a3+MySa0+Cs+AoqEK/IbB+f5szwmyVTENOjzz/JEgm2t31FtHmUUMFcQg5VQ==
    00088 #//# MeVis end
    00089

All Classes Namespaces Files Functions Variables Enumerator Friends