まず更新、私のスクリプトがあります:はPostgreSQLのタプルからデータを列全体(psycopg2)すべての
import psycopg2
import sys
data = ((160000,),
(40000,),
(75000,),
)
def main():
try:
connection = psycopg2.connect("""host='localhost' dbname='postgres'
user='postgres'""")
cursor = connection.cursor()
query = "UPDATE Planes SET Price=%s"
cursor.executemany(query, data)
connection.commit()
except psycopg2.Error, e:
if connection:
connection.rollback()
print 'Error:{0}'.format(e)
finally:
if connection:
connection.close()
if __name__ == '__main__':
main()
このコードのコースの作品ではなく、私が好きな方法インチこれは良い 'Price'列全体を更新しますが、 'data'(75000)の最後の値を使用することによってのみ更新されます。
(1, 'Airbus', 75000, 'Public')
(2, 'Helicopter', 75000, 'Private')
(3, 'Falcon', 75000, 'Military')
私の欲求の出力は次のようになります。私はそれを修正することができますどのように、
今(1, 'Airbus', 160000, 'Public')
(2, 'Helicopter', 40000, 'Private')
(3, 'Falcon', 75000, 'Military')
?