sqlite3 - Python sqlite Internal Server Error -
i'm working on website powered python @ end. following script receives values javascript , should write same database.
import cgi import sqlite3 form = cgi.fieldstorage() brand = form['brand'].value model = form['model'].value db = sqlite3.connect("dbase.db") query = "insert requests (brand, model) values (?, ?)" db.execute(query, (brand, model,)) db.commit() db.close()
but invoking script returns 500 internal server error
. surprise, following code, run independently on terminal works perfect.
import sqlite3 brand = 'nokia' model = 'lumia 625' db = sqlite3.connect("dbase.db") query = "insert requests (brand, model) values (?, ?)" db.execute(query, (brand, model,)) db.commit() db.close()
i'm using python 2.7.5 , running on lighttpd server. also, db.execute()
portion error occurs. how can correct problem?
this might happen not having database dbase
, table requests
.you need database , table inserting fields.you can create database query
sqlite3 dbase.db
and next need create table like
create table requests(brand varchar(10), model varchar2(10));
then file execute
Comments
Post a Comment