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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:34:32+00:00 2026-06-01T04:34:32+00:00

I am a beginner in SQLite, so please bear with me if what i’m

  • 0

I am a beginner in SQLite, so please bear with me if what i’m about to ask seems silly.

I currently have a database called “Status”, with two columns “stamp” and “messages”. “messages” contains a text, and “stamp” contains a time stamp.

I would like to read the last 10 entries of this database, and display them to a HTML page.

The code I am using to read from database is:

@cherrypy.expose
def readStatus(self):
    con = lite.connect('static/database/Status.db')
    output = ""
    with con:    

        cur = con.cursor()    
        cur.execute("SELECT messages FROM Status ORDER BY stamp DESC LIMIT 5")
        print "The Status database now contains:"

        for row in cur:
            print row
            output = output + row

    return output

The code I am using to print the messages onto an HTML page is

@cherrypy.expose
def homepage(self):
    """Display the home page showing status update
    """
    page = get_file(staticfolder+"/html/homePage.html")
    page = page.replace("$STATUS", self.readStatus())
    return page

However, I am getting this error message:

File "proj1base.py", line 133, in homepage
    page = page.replace("$STATUS", self.readStatus())
  File "proj1base.py", line 305, in readStatus
    output = output + row
TypeError: cannot concatenate 'str' and 'tuple' objects

I’m not entirely sure what this means, I assume it is saying that the type between ‘output’ and ‘row’ is mismatching. However, what ‘row’ should be reading is ‘messages’ column of database ‘status’, which is a string, and ‘output’ is also a string. So I don’t know what’s happening and is wondering if anyone could help?

  • 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-01T04:34:34+00:00Added an answer on June 1, 2026 at 4:34 am

    While you’re querying for only one column, SQLite also supports querying for multiple columns. However, for consistency, Python always puts them in a tuple. You probably want to get the first element of the tuple, which will be a string:

    output = output + row[0]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beginner programmer here. So bear with me. I have a simple python program. print
I'm working with a sqlite database, using python/django. I would need to have my
I am a beginner SQLite user and has run into some trouble, hoping to
What resources are great to provide information on using SQLite for beginner iPhone developers?
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
Beginner question: I have a dictionary where the values are lists of (a variable
A beginner question, bear with me: I'm just wondering under what circumstances one should
Absolute beginner question: I have a template file index.html that looks like this: ...
Beginner programmer here....hope it makes sense :) I have created a console app that
Beginner here, I have a simple question. In Android what would be the best

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.