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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:54:37+00:00 2026-06-14T03:54:37+00:00

I am new to Python 2.6. I have been trying to fetch date datetime

  • 0

I am new to Python 2.6. I have been trying to fetch date datetime value which is in yyyy-mm-dd hh:m:ss format back in my Python program. On checking the column type in Python I get the error: 'buffer' object has no attribute 'decode'. I want to use the strptime() function to split the date data and use it but I can’t find how to convert a buffer to string. The following is a sample of my code (also available here):

conn = sqlite3.connect("mrp.db.db", detect_types=sqlite3.PARSE_DECLTYPES)
cursor = conn.cursor()
qryT = """
    SELECT dateDefinitionTest FROM t
    WHERE IDproject = 4 AND IDstatus = 5
    ORDER BY priority, setDate DESC
"""
rec = (4,4)
cursor.execute(qryT,rec)
resultsetTasks = cursor.fetchall()
cursor.close()  # closing the resultset
for item in resultsetTasks:
    taskDetails = {}
    _f = item[10].decode("utf-8")

The exception I get is:

'buffer' object has no attribute 'decode'
  • 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-14T03:54:38+00:00Added an answer on June 14, 2026 at 3:54 am

    I am not exactly sure what your problem may be. The following is a working example of what you are trying to achieve, which hopefully will help you:

    #!/usr/bin/env python
    
    import datetime
    import sqlite3
    
    conn = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES)
    cursor = conn.cursor()
    cursor.execute("CREATE TABLE t (dateDefinitionTest DATETIME)")
    cursor.execute("INSERT INTO t VALUES (?)", (datetime.datetime.now(),))
    query = "SELECT dateDefinitionTest FROM t"
    cursor.execute(query)
    for row in cursor.fetchall():
        dt = datetime.datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S.%f")
        print(repr(dt))
        print(dt.strftime("%Y-%m-%d %H:%M:%S.%f"))
    cursor.close()
    

    which outputs:

    datetime.datetime(2012, 11, 11, 16, 40, 26, 788966)
    2012-11-11 16:40:26.788966
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Python and I have been trying to search through html with
I'm new to python and have been trying to figure this out all day.
I am very new to Python and I have been trying to detect missing
I am new to python and I have been trying to change my php
I am reasonably new to the inner workings of Python. I have been trying
Regards, SO I am new to python and Perl. I have been trying to
I am brand new to Python, and have been trying to get the Django
I am still new to Python, and I have been trying to improve the
I am new to the Python C binding swig and have been trying to
I'm new to Django (and Python) and I have been trying to work out

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.