You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
running with commented block, prints empty. uncommenting, works fine, I might be missing something but it shouldn't do that. (Product is defined in 'product' module, not here in other.py, but in order for fetching data to work, I must also define the same class here)
from redis_om import HashModel
from product import redis, Product
# class Product(HashModel):
# class Meta:
# database = redis
print(list(Product.all_pks()))
code is isolated, I'm going insane, running product.py results in 2 products being printed. using that product.py as a module in other.py results in Product.all_pks returning empty, Product.get raising Exception for data not found. What am I doing wrong?
running it from vscode inside venv, happens on both regular and debug run. I can see the connection from other.py but I don't know what or where to dig deeper to figure out what's wrong.
product.py
from redis_om import get_redis_connection, HashModel
redis = get_redis_connection(
host="-",
port=12262,
password="-",
decode_responses=True
)
class Product(HashModel):
class Meta:
database = redis
print(list(Product.all_pks()))
# ran as main prints 2 products
other.py
from redis_om import get_redis_connection, HashModel
import product
# ran as main without line below it runs the other scripts but prints []
# print(list(product.Product.all_pks())) # this also prints []
more testing, other.py, using redis from main but defining the Product again
from redis_om import HashModel
from product import redis, Product
class Product(HashModel):
class Meta:
database = redis
import product # just trying, prints []
print(list(Product.all_pks())) # prints 2 products
it's not the nested class,
print(Product._meta.database)
returns the same with and without the commented part
The text was updated successfully, but these errors were encountered:
TLDR:
running with commented block, prints empty. uncommenting, works fine, I might be missing something but it shouldn't do that. (Product is defined in 'product' module, not here in other.py, but in order for fetching data to work, I must also define the same class here)
code is isolated, I'm going insane, running product.py results in 2 products being printed. using that product.py as a module in other.py results in Product.all_pks returning empty, Product.get raising Exception for data not found. What am I doing wrong?
running it from vscode inside venv, happens on both regular and debug run. I can see the connection from other.py but I don't know what or where to dig deeper to figure out what's wrong.
product.py
other.py
more testing, other.py, using redis from main but defining the Product again
it's not the nested class,
returns the same with and without the commented part
The text was updated successfully, but these errors were encountered: