コード例 #1
0
    def insert_locus(self, locus):
        db = DatabaseConnection()
        cur = db.connection.cursor()

        try:
            cur.execute(
                """INSERT  INTO  tbl_locus  (id, locus_type, sector_trench, space_room, description)
                        VALUES(%s, %s, %s, %s, %s)""",
                (locus.locus_id, locus.locus_type, locus.sector_trench,
                 locus.space_room, locus.description))

        except:
            print "cant insert", sys.exc_info()
コード例 #2
0
    def get_locus(self, locus_id):
        try:
            db = DatabaseConnection()
            cur = db.connection.cursor()
            cur.execute("""select * from tbl_locus WHERE id = %s""",
                        [str(locus_id)])
            locus = cur.fetchall()

            return Locus(locus[0][0], locus[0][1], locus[0][2], locus[0][3],
                         locus[0][4])
            db.connection.close()

        except psycopg2.Error, e:
            # print "Error %d: %s" % (e.args[0], e.args[1])
            print e
コード例 #3
0
    def get_all_locus(self):

        try:
            db = DatabaseConnection()
            cur = db.connection.cursor()
            cur.execute("""SELECT * FROM tbl_locus""")
            result = cur.fetchall()

            locus_list = []
            for locus in result:
                locus_list.append(
                    # Locus(locus[0], locus[1], locus[2], locus[3], locus[4], locus[5], locus[6], locus[7], locus[8]))
                    Locus(locus[0], locus[1], locus[2], locus[3], locus[4]))

        except psycopg2.Error, e:
            print "Error %d: %s" % (e.args[0], e.args[1])
コード例 #4
0
    def update_locus(self, locus, locus_id):

        db = DatabaseConnection()
        cur = db.connection.cursor()

        try:
            cur.execute(
                """update tbl_locus set locus_type = %s, sector_trench = %s, space_room = %s, description = %s 
                            where id = %s""",
                (locus.locus_type, locus.sector_trench, locus.space_room,
                 locus.description, locus_id))

        except (Exception, psycopg2.DatabaseError) as error:
            print(error)
        finally:
            if db.connection is not None:
                db.connection.close()
コード例 #5
0
import sys
from PyQt4 import QtGui, QtCore

import psycopg2 as mdb
from postgresConnection import DatabaseConnection
#from locusDetailed import *

db = DatabaseConnection()
cur = db.connection.cursor()


class LocusDataEntryDialog(QtGui.QDialog):
    def __init__(self, parent=None):
        QtGui.QDialog.__init__(self, parent)

        #        self.locus = locus

        self.setWindowTitle('Enter Locus Data')

        self.layout = QtGui.QGridLayout(self)

        # self.LocusTypeSelect = QtGui.QComboBox(self)
        #self.LocusSubType1Select = QtGui.QComboBox(self)
        # self.LocusSubType2Select = QtGui.QComboBox(self)
        # self.LocusSubType3Select = QtGui.QComboBox(self)

        # def getlocustype(self):
        #     try:
        #         cur.execute("""SELECT * FROM tbl_locus_type""")
        #         resultsTable = cur.fetchall()
        #