python MySQLdb got invalid syntax when trying to INSERT INTO table

Posted by Michelle Jun Lee on Stack Overflow See other posts from Stack Overflow or by Michelle Jun Lee
Published on 2010-03-27T20:11:54Z Indexed on 2010/03/27 20:23 UTC
Read the original article Hit count: 533

Filed under:
|
|
|
|
## COMMENT OUT below just for reference  
""   
cursor.execute ("""  
    CREATE TABLE yellowpages  
    (  
        business_id     BIGINT(20) NOT NULL AUTO_INCREMENT,  
        categories_name VARCHAR(255),  
        business_name   VARCHAR(500) NOT NULL,  
        business_address1 VARCHAR(500),  
        business_city VARCHAR(255),  
        business_state VARCHAR(255),  
        business_zipcode VARCHAR(255),  
        phone_number1 VARCHAR(255),  
        website1 VARCHAR(1000),  
        website2 VARCHAR(1000),  
        created_date datetime,  
        modified_date datetime,  
        PRIMARY KEY(business_id)  
    )  
""")  
""  
## TOP COMMENT OUT (just for reference)  

## code  

website1g = "http://www.triman.com"  
business_nameg = "Triman Sales Inc"  
business_address1g = "510 E Airline Way"  
business_cityg = "Gardena"  
business_stateg = "CA"  
business_zipcodeg = "90248"  
phone_number1g = "(310) 323-5410"  
phone_number2g = ""  
website2g = ""  

cursor.execute ("""  
    INSERT INTO yellowpages(categories_name, business_name, business_address1, business_city, business_state, business_zipcode, phone_number1, website1, website2)  
    VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')  
""", (''gas-stations'', business_nameg, business_address1g, business_cityg, business_stateg, business_zipcodeg, phone_number1g, website1g, website2g))  


cursor.close()
conn.close()

I keep getting this error

File "testdb.py", line 51
    """, (''gas-stations'', business_nameg, business_address1g, business_cityg, business_stateg, business_zipcodeg, phone_number1g, website1g, website2g))  
          ^  
SyntaxError: invalid syntax  

any idea why?

By the way, the up arrow is pointing to website1g (the b character) .

Thanks for the help in advance

© Stack Overflow or respective owner

Related posts about python

Related posts about mysqldb