Trees | Indices | Help |
---|
|
1 # 2 # Copyright (c) 2008--2016 Red Hat, Inc. 3 # 4 # This software is licensed to you under the GNU General Public License, 5 # version 2 (GPLv2). There is NO WARRANTY for this software, express or 6 # implied, including the implied warranties of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 8 # along with this software; if not, see 9 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 10 # 11 # Red Hat trademarks are not licensed under GPLv2. No permission is 12 # granted to use or replicate Red Hat trademarks that are incorporated 13 # in this software or its documentation. 14 # 15 # A collection of classes and functions for handy data manipulation 16 # This file includes common classes and functions that are used by 17 # misc parts of the RHN backend 18 # 19 # Before changing any of this stuff, please grep through the sources to 20 # check how the function/class you are about to modify is used first. 21 # Or ask gafton. 22 # 23 24 import string 25 2628 """ This statement builds a sql statement for an insert 29 of 'items' into "table" indexed by "hash_name" 30 """ 31 sql = "insert into %s ( %s, %s ) values ( :p0, %s )" % ( 32 table, hash_name, 33 string.join([a[0] for a in items], ", "), 34 string.join([":p_%s" % a[0] for a in items], ", ")) 35 pdict = {"p0": None} # This must be reset after we return from this call 36 list(map(pdict.update, [{"p_%s" % a[0]: a[1]} for a in items])) 37 return sql, pdict38 3941 """ This statement builds a sql statement for an update 42 of 'items' into "table" indexed by "hash_name" 43 """ 44 sql = "update %s set %s where %s = :p0" % ( 45 table, 46 string.join(["%s = :p_%s" % (a, a) for a in [a[0] for a in items]], 47 ", "), 48 hash_name) 49 pdict = {"p0": None} # This must be reset after we return from this call 50 list(map(pdict.update, [{"p_%s" % a[0]: a[1]} for a in items])) 51 return sql, pdict52
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Wed Mar 4 07:37:47 2020 | http://epydoc.sourceforge.net |