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.

error on fetch or filtering

See original GitHub issue

Hello. I’m following the starter tutorial at https://www.youtube.com/watch?v=jJYHUp9ZeTY&t=56s.

I’m getting error when trying to fetch data from a HashModel. For example: result = Product.all_pks() gets: redis.exceptions.ResponseError: syntax error

For creating: exists = Product.find(Product.name == product.name).first() gets: TypeError: 'NoneType' object is not subscriptable

Creating is OK.

Versions: Python version: 3.9.7 redis-om-python: 0.0.20

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alecvinentcommented, Apr 7, 2022

In deed, but it’s still failing. I’m willing the issue may be due to the OS. I’ll test on Ubuntu, cause currently using Windows 10.

0reactions
simonprickettcommented, Apr 7, 2022

Is the value of REDIS_DB > 0? RediSearch functionality only operates on DB 0 so if you’re using search and the Migrator that will fail silently (I’m about to put out a release that will detect use of DB > 0 and raise a proper error). This works locally for me:

$ python issue.py
['01G025DB81XWJ766JEHPYDV2HH']
from redis_om import Field, HashModel, get_redis_connection

REDIS_HOST = "127.0.0.1"
REDIS_PORT = 6379
REDIS_DB = 0

redis_instance = get_redis_connection(
    host=REDIS_HOST,
    port=REDIS_PORT,
    password='',
    db=REDIS_DB,
    decode_responses=True
)

class Product(HashModel):
    name: str = Field(index=True)
    price: float
    quantity: int

    class Meta:
        database: redis_instance

a_product = Product(
    name="Test Product",
    price=10.99,
    quantity=4
)

a_product.save()

all_product_keys = list(Product.all_pks())
print(all_product_keys)

You could simplify this too as you don’t need all the connection stuff:

$ export REDIS_OM_URL=redis://127.0.0.1:6379
$ python issue.py
['01G025GN8RQ1J0WRV5G96G0MM4']

You don’t even need to set REDIS_OM_URL in this case as localhost, 6379, no password are the defaults.

Simplified code:

from redis_om import Field, HashModel

class Product(HashModel):
    name: str = Field(index=True)
    price: float
    quantity: int

a_product = Product(
    name="Test Product",
    price=10.99,
    quantity=4
)

a_product.save()

all_product_keys = list(Product.all_pks())
print(all_product_keys)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Difficulty when trying to filter data from fetch Api - SitePoint
Hello everyone, I have problem filtering this data result I got from fetch API… For an example, when the England button is clicked, ......
Read more >
Code is not working as i want to fetch data based on filter
i tried console.log to get the email and other thing but the code is not showing nothing even not a single error. here...
Read more >
Unable to fetch filter values. Refresh later or use the "Custom ...
Unfortunatly, while I am trying to use this filter I got this error: “Unable to fetch filter values. Refresh later or use the...
Read more >
Error message: 'Query filter cannot be specified on a query ...
The error is caused when adding a Filter Query-Wizard, Dialog-setup and/or the Default ranges. The issue only exists if the Query contains two ......
Read more >
Solved: Error message : Unable to fetch app definition. Er...
I have a working app with data filtered out by the security filters. When logged in to the app with custom log in...
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