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

  • Home
  • SEARCH
  • 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 429163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:44:53+00:00 2026-05-12T19:44:53+00:00

Hey there, was wondering if anyone could help a newbie on SQL and Python.

  • 0

Hey there, was wondering if anyone could help a newbie on SQL and Python. I thought I had a pretty decent grasp of it, however something odd happened recently.

Here is the the following code snipped from a larger portion:

  try:
      self.db.query("SELECT * FROM account WHERE email = '{0}' AND pass = '{1}'".format(self.mail.strip(self.bchars),self.pw.strip(self.bchars)))
  except MySQLdb.Error, e:
      print "Error %d: %s" % (e.args[0], e.args[1])

  exists = self.db.store_result().fetch_row()
  print "EXISTS",exists

It use to print this:

EXISTS ((2, 'test@test.com', '1234', 1, 0, 2161, '192.168.1.47', 0),)

Now, it prints this:
It use to print this:

EXISTS ((2L, 'test@test.com', '1234', 1L, 0L, 2161, '192.168.1.47', 0L),)

I have no idea where these L’s came from. I checked the SQL Database and even reloaded it to be sure. I have reverted all my code for the last day (where all was functioning), but still can’t find a solution. I have also tried searching, but I am not even sure what this problem is even called so it’s hard to search. Thanks for any help or information anyone can provide.

  • 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-12T19:44:53+00:00Added an answer on May 12, 2026 at 7:44 pm

    I think, python’s dbapi is supposed to always return integer-fields as long.

    Anyway, 10L, 5L and so on is the way repr (which is used on every item of a tuple in your case) works for longs.

    One more thing. I see, you are using MySQLdb. In that case, I strongly suggest, that you stop using the c-api wrapper, but instead use the “real” interface, that has all that automatic conversion/escaping and a bunch of other wonderful things (dict-cursors for one).

    This will save you a lot of grief and WILL make your code more stable/secure. In short, just forget about _mysql. Trust me.

    Your example can be rewritten as this (using the proper interface):

    import MySQLdb
    
    db = MySQLdb.connect(host=your_host, db=your_db,
                         user=your_user, passwd=your_password)
    
    cur = db.cursor()
    cur.execute("""SELECT * FROM account WHERE email = %s AND pass = %s """,
                (self.mail, self.pw))
    result = cur.fetchall()
    print "exists:", result
    

    This does the same as you are doing (except the error handling), but without manual string-formatting, escaping and so on.

    I know, this is going to be downvoted for irrelevance, probably, but if this answer helps even a single person to start using the proper database api, that would be really great.

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

Sidebar

Ask A Question

Stats

  • Questions 210k
  • Answers 210k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I found it myself. Apparently, even if windows is set… May 12, 2026 at 9:57 pm
  • Editorial Team
    Editorial Team added an answer Try woking with UPDATE … FROM and an alias. UPDATE… May 12, 2026 at 9:57 pm
  • Editorial Team
    Editorial Team added an answer You can't really do this with generic relations, because there's… May 12, 2026 at 9:57 pm

Related Questions

I've had this problem a few times and solved it the same way. But
Hey I was wondering if there were any way to upload images in ASP?
So I was wondering if there are any major differences between the various implementations
Hey, I'm new to Rails and Ruby in general. I was wondering if it's
Hey all, looking to reduce the code on my c# if statements as there

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.