Exemplo n.º 1
0
    def select_parts_by_value(self, val, connection):
        ''' Return the Part(s) of given value in a list. '''
        parts = []
        try:
            cur = connection.cursor()

            sql = 'SELECT * FROM parts WHERE value=? INTERSECT SELECT * FROM parts WHERE project=?'
            params = (val, self.name)
            for row in cur.execute(sql, params):
                parts.append(Part.new_from_row(row, connection, self))

        finally:
            cur.close()
            return parts
Exemplo n.º 2
0
	def select_parts_by_value(self, val, connection):
		''' Return the Part(s) of given value in a list. '''
		parts = []
		try:
			cur = connection.cursor()
			
			sql = 'SELECT * FROM parts WHERE value=? INTERSECT SELECT * FROM parts WHERE project=?'
			params = (val, self.name)
			for row in cur.execute(sql, params):
				parts.append(Part.new_from_row(row, connection, self))
			
		finally:
			cur.close()
			return parts
Exemplo n.º 3
0
    def select_parts_by_name(self, name, connection):
        ''' Return the Part(s) of given name. '''
        parts = []
        try:
            cur = connection.cursor()

            #sql = 'SELECT * FROM parts WHERE name=? INTERSECT SELECT * FROM parts WHERE project=?'
            sql = 'SELECT * FROM parts WHERE name=? AND project=?'
            params = (name, self.name)
            for row in cur.execute(sql, params):
                parts.append(Part.new_from_row(row, connection, self))

        finally:
            cur.close()
            return parts
Exemplo n.º 4
0
	def select_parts_by_name(self, name, connection):
		''' Return the Part(s) of given name. '''
		parts = []
		try:
			cur = connection.cursor()
			
			#sql = 'SELECT * FROM parts WHERE name=? INTERSECT SELECT * FROM parts WHERE project=?'
			sql = 'SELECT * FROM parts WHERE name=? AND project=?'
			params = (name, self.name)
			for row in cur.execute(sql, params):
				parts.append(Part.new_from_row(row, connection, self))
			
		finally:
			cur.close()
			return parts
Exemplo n.º 5
0
	def select_parts_by_product(self, prod, connection):
		''' Return the Part(s) of given product in a list. '''
		parts = []
		try:
			cur = connection.cursor()
			if prod is None or prod == '' or len(prod) == 0 or prod == 'NULL':
				sql = 'SELECT * FROM parts WHERE project=? AND product IS NULL'
				params = (self.name,)
			else:
				sql = 'SELECT * FROM parts WHERE product=? AND project=?'
				params = (prod, self.name,)
			for row in cur.execute(sql, params):
				parts.append(Part.new_from_row(row, connection, self))
			
		finally:
			cur.close()
			return parts
Exemplo n.º 6
0
    def select_parts_by_product(self, prod, connection):
        ''' Return the Part(s) of given product in a list. '''
        parts = []
        try:
            cur = connection.cursor()
            if prod is None or prod == '' or len(prod) == 0 or prod == 'NULL':
                sql = 'SELECT * FROM parts WHERE project=? AND product IS NULL'
                params = (self.name, )
            else:
                sql = 'SELECT * FROM parts WHERE product=? AND project=?'
                params = (
                    prod,
                    self.name,
                )
            for row in cur.execute(sql, params):
                parts.append(Part.new_from_row(row, connection, self))

        finally:
            cur.close()
            return parts