Insert values in python manage.py shell using custom sql

28 views
Skip to first unread message

Vishak Raj

unread,
Aug 23, 2018, 7:30:51 AM8/23/18
to Django users
hello,

i am inserting the values in the table using custome sql in django shell..
p.execute('INSERT INTO webapp_information VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',i)
i is the list of values
it shows the error:OperationalError: table webapp_information has 32 columns but 31 values were supplied
I created the only 31 columns in models.py

What to do.. thanks

Vinod Kumar

unread,
Aug 23, 2018, 7:51:06 AM8/23/18
to django...@googlegroups.com
By default model have id column , so you have to put value of id.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/10ad145e-5e0b-4d52-a8c9-54af6fa69fba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

************************************************************************

This e-mail and all attachments are intended solely for use by the intended recipient and may contain confidential / proprietary information of KiwiTech, LLC, subject to important disclaimers and conditions including restrictions on the use, disclosure, transfer or export of such information. If you have received this message in error or are not the named recipient(s), please immediately notify the sender at the telephone number stated above or by reply e-mail and delete this e-mail from your computer

Vishak Raj

unread,
Aug 23, 2018, 1:50:32 PM8/23/18
to django...@googlegroups.com
Hello

Thanks for replying..

I have a confusion 

In normal python shell, we import sqlite3 and insert values without giving the  Id or primary key..

Why we giving primary key in django..
Is it possible to insert values without primary key like we give in python shell..

Thanks in advance

On Thursday, August 23, 2018, 'Vinod Kumar' via Django users <django...@googlegroups.com> wrote:
By default model have id column , so you have to put value of id.

On Thu, Aug 23, 2018, 5:00 PM Vishak Raj <vishak...@gmail.com> wrote:
hello,

i am inserting the values in the table using custome sql in django shell..
p.execute('INSERT INTO webapp_information VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',i)
i is the list of values
it shows the error:OperationalError: table webapp_information has 32 columns but 31 values were supplied
I created the only 31 columns in models.py

What to do.. thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

************************************************************************

This e-mail and all attachments are intended solely for use by the intended recipient and may contain confidential / proprietary information of KiwiTech, LLC, subject to important disclaimers and conditions including restrictions on the use, disclosure, transfer or export of such information. If you have received this message in error or are not the named recipient(s), please immediately notify the sender at the telephone number stated above or by reply e-mail and delete this e-mail from your computer

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.


--
vishakraj

Aware Fun

unread,
Aug 23, 2018, 2:43:32 PM8/23/18
to django...@googlegroups.com
Primary key is a unique kye that differentiate you values like in order 1,2,3 like this or u can say that your values are are stored in order.In django when u create object and give  values first it by default assign the primary key to 1.



rahul

On Thu, Aug 23, 2018, 11:20 PM Vishak Raj <vishak...@gmail.com> wrote:
Hello

Thanks for replying..

I have a confusion 

In normal python shell, we import sqlite3 and insert values without giving the  Id or primary key..

Why we giving primary key in django..
Is it possible to insert values without primary key like we give in python shell..

Thanks in advance

On Thursday, August 23, 2018, 'Vinod Kumar' via Django users <django...@googlegroups.com> wrote:
By default model have id column , so you have to put value of id.

On Thu, Aug 23, 2018, 5:00 PM Vishak Raj <vishak...@gmail.com> wrote:
hello,

i am inserting the values in the table using custome sql in django shell..
p.execute('INSERT INTO webapp_information VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',i)
i is the list of values
it shows the error:OperationalError: table webapp_information has 32 columns but 31 values were supplied
I created the only 31 columns in models.py

What to do.. thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

************************************************************************

This e-mail and all attachments are intended solely for use by the intended recipient and may contain confidential / proprietary information of KiwiTech, LLC, subject to important disclaimers and conditions including restrictions on the use, disclosure, transfer or export of such information. If you have received this message in error or are not the named recipient(s), please immediately notify the sender at the telephone number stated above or by reply e-mail and delete this e-mail from your computer

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.


--
vishakraj

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Aware Fun

unread,
Aug 23, 2018, 2:43:34 PM8/23/18
to django...@googlegroups.com
We dont need to give primary key it automatically define the key.

rahul

On Thu, Aug 23, 2018, 11:20 PM Vishak Raj <vishak...@gmail.com> wrote:
Hello

Thanks for replying..

I have a confusion 

In normal python shell, we import sqlite3 and insert values without giving the  Id or primary key..

Why we giving primary key in django..
Is it possible to insert values without primary key like we give in python shell..

Thanks in advance

On Thursday, August 23, 2018, 'Vinod Kumar' via Django users <django...@googlegroups.com> wrote:
By default model have id column , so you have to put value of id.

On Thu, Aug 23, 2018, 5:00 PM Vishak Raj <vishak...@gmail.com> wrote:
hello,

i am inserting the values in the table using custome sql in django shell..
p.execute('INSERT INTO webapp_information VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',i)
i is the list of values
it shows the error:OperationalError: table webapp_information has 32 columns but 31 values were supplied
I created the only 31 columns in models.py

What to do.. thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

************************************************************************

This e-mail and all attachments are intended solely for use by the intended recipient and may contain confidential / proprietary information of KiwiTech, LLC, subject to important disclaimers and conditions including restrictions on the use, disclosure, transfer or export of such information. If you have received this message in error or are not the named recipient(s), please immediately notify the sender at the telephone number stated above or by reply e-mail and delete this e-mail from your computer

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.


--
vishakraj

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Vishak Raj

unread,
Aug 24, 2018, 12:53:49 AM8/24/18
to django...@googlegroups.com
Thank you..

I  am new to django,. 
How can we say the data are in order to django and it asked the value for the id column..
How can it get the last id column..
Thanks in advance

shanmu

Reply all
Reply to author
Forward
0 new messages