You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
570 B
Python
22 lines
570 B
Python
from sqlalchemy import Column, JSON, String, select
|
|
from sqlalchemy.orm import declarative_base
|
|
|
|
Base = declarative_base()
|
|
|
|
class Test(Base):
|
|
__tablename__ = 'test'
|
|
id = Column(String, primary_key=True)
|
|
meta = Column(JSON)
|
|
|
|
try:
|
|
s = select(Test).where(Test.meta["type"].as_string() == "target_reliability")
|
|
print("as_string works")
|
|
except Exception as e:
|
|
print("as_string error:", e)
|
|
|
|
try:
|
|
s = select(Test).where(Test.meta["type"].astext == "target_reliability")
|
|
print("astext works")
|
|
except Exception as e:
|
|
print("astext error:", e)
|