Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:54:30+00:00 2026-05-31T03:54:30+00:00

The problem I have is when trying to insert some values ​​in the database

  • 0

The problem I have is when trying to insert some values ​​in the database created by Django model, the values ​​are strictly numeric, but when trying to insert it I get an error:

567523
<type 'int'>
Warning: Incorrect integer value: 'id' for column 'id_unidad' at row 1
cursor.execute(sql, ('id',))

the code I’m using to insert using a mysql request is:

import MySQLdb
import _mysql

id = 567523
print id
print type(id)

sql = """INSERT INTO gprs_evento ( id_unidad ) VALUES (%s)"""

db = MySQLdb.Connect(host="localhost", user="*****",passwd="******",db="gp")
cursor = db.cursor()

try :
    cursor.execute(sql, ('id',))
    db.commit()
except _mysql.Error, e:
    print "Error %d: %s" % (e.args[0], e.args[1])

Django model I’m using is:

from django.db import models

class Evento(models.Model):
    id_unidad = models.IntegerField(max_length=15)

Attempt to insert in each field in the database:

id: 13831010240120
<type 'long'>
ip:  3235021102
<type 'long'>
e: 2
<type 'int'>
H:  102718.0
<type 'float'>
LN:  210.128871
<type 'float'>
LO:  3203.323664
<type 'float'>
V:  28.0
<type 'float'>
A:  90.0
<type 'float'>
F:  40101.0
<type 'float'>

In the model I’m using the reference of the Field types and try and IntegerField, BigIntegerField, DecimalField but nothing, I just inserted a normal number of 15 characters from Python.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:54:32+00:00Added an answer on May 31, 2026 at 3:54 am

    You’re trying to insert the string "id", rather than the value of the variable id.

    It should be:

    cursor.execute(sql, (id,))
    

    Of course, there’s no reason to be using raw SQL for this at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to insert some values into an SQL database, but continuously receiving
I'm trying to get a regexp to solve the next problem: I have some
I have a problem using the MySQLdb library. I'm trying to insert values into
Gday All, I have a baffling problem whilst trying to insert some chinese characters
I have been trying to tackle this problem , but I am having difficulty
I have been trying to solve this problem for a while, but couldn't with
Greetings, I have problem with errorPlacement, I'm trying to place the error message next
I have a problem when trying to insert certain characters through query with parameters.
I'm trying to run a simple insert query to a database. I have it
I have the same problem but a little different from Neil problems ( Error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.