question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'str' object has no attribute 'unwrap'

See original GitHub issue

I’m trying to retrieve rows from the database and get this error. My table looks as follows:

class Post(Model):
    date = DateField()
    user = ForeignKeyField(User, backref='numbers')
	number1 = DecimalField(6,2)
    number2 = DecimalField(6,2)

    class Meta:
		database = SqliteDatabase('data.db')
        primary_key = CompositeKey('date', 'user')

What can be the problem?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
coleifercommented, Jan 20, 2020

You need to read the docs. It’s nowhere indicated that you pass string field-names into the select() method. You use the field instances themselves.

Post.select(Post.date, Post.number1, ...)

Also selecting Post.user will just grab the user_id.

0reactions
Rizhiycommented, Jan 20, 2020
Traceback (most recent call last):
  File "tmp.py", line 22, in <module>
    for stuff in Post.select('date', 'user', 'number1'):
  File "/home/rizhiy/anaconda3/envs/data/lib/python3.7/site-packages/peewee.py", line 4287, in next
    self.cursor_wrapper.iterate()
  File "/home/rizhiy/anaconda3/envs/data/lib/python3.7/site-packages/peewee.py", line 4203, in iterate
    self.initialize()  # Lazy initialization.
  File "/home/rizhiy/anaconda3/envs/data/lib/python3.7/site-packages/peewee.py", line 7251, in _initialize_columns
    node = raw_node.unwrap()
AttributeError: 'str' object has no attribute 'unwrap'
Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError 'str' object has no attribute - Stack Overflow
I am new to python and I get stuck in this error. I want to print names and years of birth of animals...
Read more >
AttributeError: 'str' object has no attribute 'Id' - Developers
So i feed the current view (as done so by the guys in the above mentioned link), which in the Python script is...
Read more >
AttributeError: 'str' object has no attribute 'send' : r/learnpython
Im trying to get text from a entry in tkinter and send it to the server but it keeps doing this. AttributeError: 'str'...
Read more >
inspect — Inspect live objects — Python 3.11.1 documentation
For example, signature() uses this to stop unwrapping if any object in the chain has a __signature__ attribute defined. ValueError is raised if...
Read more >
attribute error peewee (Example) | Treehouse Community
_meta.db_table) AttributeError: 'str' object has no attribute '_meta'. import datetime from peewee import * db = SqliteDatabase('diary.db') ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found