#
# addsc.py: add sponsorship class data
#
# PostgreSQL 9 version
#
from db import conn, curs, Error, pmark

#
# Look at the code in cratdb.py, or your database, for column names
#
# We need to insert the sponsorship class name and the price - the
# database should automagically provide the primary key for each row
#
# If you haven't provided an automatically-generated primary key then
# you may have to modify the data to include it
#
data = [
    ('Platinum', 5000),
    ('Gold', 2000),
    ('Silver', 500),
    ('Insert', 200),
    ('Media', 0)]

for row in data:
    # execute an appropriate SQL INSERT statement
    curs.execute("INSERT INTO sponsorship_spclass (spcname, spccost) VALUES (%s, %s)" % ((pmark,) * 2), row)

#
# Make sure that you have made your changes permanent before exiting
#
# (You can do this per-row or just once at the end of the program -
# what are the relative mertis of each choice?)
#
conn.commit()
