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 8691025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:02:13+00:00 2026-06-13T00:02:13+00:00

I am working on python and tried to fetch some data from Mysql Database

  • 0

I am working on python and tried to fetch some data from Mysql Database and following is the query

import MySQLdb as mdb
page  = 1
perpage = 3
offset = (int(page) - 1) * perpage
conn = mdb.connect(user='root', passwd='redhat', db='Python_Web', host='localhost')
cursor_posts = conn.cursor()
posts = "select * from projects LIMIT = %s OFFSET = %s " %(offset,perpage)
cursor_posts.execute(posts)

Error:

ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/IPython/ultraTB.py", line 667, in text
    locals,formatvalue=var_repr))
  File "/usr/lib64/python2.7/inspect.py", line 885, in formatargvalues
    specs.append(strseq(args[i], convert, join))
  File "/usr/lib64/python2.7/inspect.py", line 840, in strseq
    return convert(object)
  File "/usr/lib64/python2.7/inspect.py", line 882, in convert
    return formatarg(name) + formatvalue(locals[name])
KeyError: 'connection'

IPython's exception reporting continues...

---------------------------------------------------------------------------
ProgrammingError                          Traceback (most recent call last)

/home/local/user/python_webcode/<ipython console> in <module>()

/usr/lib64/python2.7/site-packages/MySQLdb/cursors.pyc in execute(self, query, args)
    172             del tb
    173             self.messages.append((exc, value))
--> 174             self.errorhandler(self, exc, value)
    175         self._executed = query
    176         if not self._defer_warnings: self._warning_check()

/usr/lib64/python2.7/site-packages/MySQLdb/connections.pyc in defaulterrorhandler(***failed resolving arguments***)
     34     del cursor
     35     del connection
---> 36     raise errorclass, errorvalue
     37 
     38 re_numeric_part = re.compile(r"^(\d+)")

ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 0 OFFSET = 3' at line 1")

Can anyone let me know whats wrong in my query above,
actually i am trying to achieve pagination in python using web.py framework

  • 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-06-13T00:02:14+00:00Added an answer on June 13, 2026 at 12:02 am

    I belive this should be just LIMIT %s OFFSET %s. No equal signs.

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

Sidebar

Related Questions

I'm working a page that needs to fetch info from some other pages and
Ive been working with Python and C++ together for some time, but never tried
I'm working on a python interface to a SQL database containing electronic parts data.
I am new to Python, and I'm working on writing some database code using
I am working with python plugins.I used list to store some values as below:
Why isn't this simple Python code working? import urllib file = urllib.urlopen('http://www.google.com') print file.read()
I'm working with Django for python. I've tried to install Markdown 2.0.3 for python
Working with Django 1.1 on Python 2.6.4, trying to execute the following: user =
Im working on a CMS for appengine using python, I have a form page
Working with python 2.7. The following code allows me to input the winning percentage

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.