Python Problem

5 views
Skip to first unread message

Manpreet Dhiman

unread,
Oct 12, 2015, 10:51:07 AM10/12/15
to lugg...@googlegroups.com
Hello everyone

I am creating a database for form and I am using a python for
this.First I connect database and create and insert values into it
using python script . But My another script gets values from the form,
But does not store them in database and it does not have any error.

Help me.

--
Manpreet Dhiman.
Gmail: manpre...@gmail.com.
Blog: https://manpreet9112.wordpress.com

Amitt Bhardwj

unread,
Oct 12, 2015, 10:53:26 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 8:21 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
> Hello everyone
>
> I am creating a database for form and I am using a python for
> this.First I connect database and create and insert values into it
> using python script . But My another script gets values from the form,
> But does not store them in database and it does not have any error.
>
> Help me.


Show the code

--
Everyone starts as a noob. Not everyone ends like a pro...
Amitt Bhardwj
Blog: amittbhardwj.wordpress.com
Github: https://github.com/amittbhardwj
LinkedIn: https://in.linkedin.com/in/amittbhardwj

Manpreet Dhiman

unread,
Oct 12, 2015, 11:03:08 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 8:23 PM, Amitt Bhardwj <amitt....@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 8:21 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>> Hello everyone
>>
>> I am creating a database for form and I am using a python for
>> this.First I connect database and create and insert values into it
>> using python script . But My another script gets values from the form,
>> But does not store them in database and it does not have any error.
>>
>> Help me.
>
>
> Show the code

I did not use 2 files for html and python. I am doing experiment so I
did all in one file. See

https://docs.google.com/document/d/1-3g8aY3BWkhAS35yNR3KX9dRAkA9zjpJqGGzboDgWeE/pub

Amitt Bhardwj

unread,
Oct 12, 2015, 11:13:36 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 8:33 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
> I did not use 2 files for html and python. I am doing experiment so I
> did all in one file. See
>
> https://docs.google.com/document/d/1-3g8aY3BWkhAS35yNR3KX9dRAkA9zjpJqGGzboDgWeE/pub


>> print "<h2>Hello!!!</h2>"

print "<h2>Your income is:"+income+"</h2>"

print "</body>"

print "</html>" <<

Is this code displaying the income value on browser?
Also, Try printing the the values of fname, lname, age, gender,
income. See if that is giving an error.

Manpreet Dhiman

unread,
Oct 12, 2015, 11:25:44 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 8:43 PM, Amitt Bhardwj <amitt....@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 8:33 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>> I did not use 2 files for html and python. I am doing experiment so I
>> did all in one file. See
>>
>> https://docs.google.com/document/d/1-3g8aY3BWkhAS35yNR3KX9dRAkA9zjpJqGGzboDgWeE/pub
>
>
>>> print "<h2>Hello!!!</h2>"
>
> print "<h2>Your income is:"+income+"</h2>"
>
> print "</body>"
>
> print "</html>" <<
>
> Is this code displaying the income value on browser?
> Also, Try printing the the values of fname, lname, age, gender,
> income. See if that is giving an error.


Yes, It display all values that are entered by user after submitting.
I checked it for all field.

Mandeep Singh

unread,
Oct 12, 2015, 11:42:56 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 8:55 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
> Yes, It display all values that are entered by user after submitting.
> I checked it for all field.

Show the output of:
mysql> DESCRIBE mydatabase;

--
Mandeep Singh
http://mandeep7.wordpress.com
https://github.com/mandeeps708

“To err is human, but to really foul up everything, you need root password.”

Manpreet Dhiman

unread,
Oct 12, 2015, 11:49:32 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 9:12 PM, Mandeep Singh <mande...@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 8:55 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>> Yes, It display all values that are entered by user after submitting.
>> I checked it for all field.
>
> Show the output of:
> mysql> DESCRIBE mydatabase;

I think this ERROR will be the solution

mysql> DESCRIBE mydatabase;
ERROR 1146 (42S02): Table 'mydatabase.mydatabase' doesn't exist

Mandeep Singh

unread,
Oct 12, 2015, 11:52:37 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 9:19 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
> I think this ERROR will be the solution
>
> mysql> DESCRIBE mydatabase;
> ERROR 1146 (42S02): Table 'mydatabase.mydatabase' doesn't exist

Oops!
Try this:
mysql> DESCRIBE EMPLOYEE;

#where EMPLOYEE is your table name.

Manpreet Dhiman

unread,
Oct 12, 2015, 11:52:51 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 9:19 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 9:12 PM, Mandeep Singh <mande...@gmail.com> wrote:
>> On Mon, Oct 12, 2015 at 8:55 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>>> Yes, It display all values that are entered by user after submitting.
>>> I checked it for all field.
>>
>> Show the output of:
>> mysql> DESCRIBE mydatabase;
>
> I think this ERROR will be the solution
>
> mysql> DESCRIBE mydatabase;
> ERROR 1146 (42S02): Table 'mydatabase.mydatabase' doesn't exist

mydatabase is a database name. DESCRIBE is used for describing tables.

Manpreet Dhiman

unread,
Oct 12, 2015, 11:56:04 AM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 9:21 PM, Mandeep Singh <mande...@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 9:19 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>> I think this ERROR will be the solution
>>
>> mysql> DESCRIBE mydatabase;
>> ERROR 1146 (42S02): Table 'mydatabase.mydatabase' doesn't exist
>
> Oops!
> Try this:
> mysql> DESCRIBE EMPLOYEE;
>
> #where EMPLOYEE is your table name.

See
mydatabase.png

Mandeep Singh

unread,
Oct 12, 2015, 12:36:25 PM10/12/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 9:26 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>> Oops!
>> Try this:
>> mysql> DESCRIBE EMPLOYEE;
>>
>> #where EMPLOYEE is your table name.
>
> See
I can't find the output of above command in the attached file.

You can add
cgitb.enable()
to CGI script to see the errors.

Manpreet Dhiman

unread,
Oct 13, 2015, 1:14:40 AM10/13/15
to lugg...@googlegroups.com
On Mon, Oct 12, 2015 at 10:05 PM, Mandeep Singh <mande...@gmail.com> wrote:
> On Mon, Oct 12, 2015 at 9:26 PM, Manpreet Dhiman <manpre...@gmail.com> wrote:
>>> Oops!
>>> Try this:
>>> mysql> DESCRIBE EMPLOYEE;
>>>
>>> #where EMPLOYEE is your table name.
>>
>> See
> I can't find the output of above command in the attached file.
See output

> You can add
> cgitb.enable()
> to CGI script to see the errors.

cgitb.enable() shows errors for tags that are not used by me.
describe.png

Manpreet Dhiman

unread,
Oct 14, 2015, 9:51:52 AM10/14/15
to lugg...@googlegroups.com
On Tue, Oct 13, 2015 at 10:44 AM, Manpreet Dhiman
<manpre...@gmail.com> wrote:

>> You can add
>> cgitb.enable()
>> to CGI script to see the errors.
>
> cgitb.enable() shows errors for tags that are not used by me.

My problem is solved yesterday. I add cgitb.enable for seeing errors
on browser. Now, script sends values from form into database just by
changing syntax of insert statement. When I use

sql ="INSERT INTO new(FN, LN, AGE, INCOME,GENDER) VALUES (%s, %s, %s,
%s, %s )"
cursor.execute(sql,(fname,lname,age,income,gender))

It solved problem. But I am little bit confused that how changed
syntax can solve problem. Because both syntax are correct.
Reply all
Reply to author
Forward
0 new messages