带有Postgresql的Python Cgi错误消息:头之前的脚本输出结束:custo
帮助错误消息:头之前的脚本输出结束:customer_add.py
选择 | 换行 | 行号
- import psycopg2
- con = None
- import cgi;
- data = cgi.FieldStorage();
- try:
- customer_id = data['customer_id'].value
- customer_lname = data['customer_lname'].value;
- customer_fname = data['customer_fname'].value;
- customer_mname = data['customer_mname'].value;
- customer_birthday = data['customer_birthday'].value;
- customer_email = data['customer_email'].value;
- customer_contact = data['customer_contact'].value;
- customer_address = data['customer_address'].value;
- customer_job = data['customer_job'].value;
- customer_company = data['customer_company'].value;
- customer = (
- (customer_id, customer_lname , customer_fname , customer_mname ,
- customer_birthday, customer_email , customer_contact, customer_address,
- customer_job, customer_company)
- )
- con = psycopg2.connect(database='fhms', user='admin', password='admin')
- cur = con.cursor()
- query = """INSERT INTO t_customer(customer_id, customer_lname,
- customer_fname, customer_mname, customer_birthday, customer_email,
- customer_contact, customer_address, customer_job, customer_company) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
- cur.execute(query, customer)
- con.commit()
- print "Customer Successfully Added"