Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.3 kB
2
Indexable
In [10]: notification = Notification()

In [11]: sa_session.add(notification)

In [12]: assert notification.id is not None

In [13]: sa_session
Out[13]: <sqlalchemy.orm.scoping.scoped_session at 0x1110e3a20>

In [14]: sa_session.table_names
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-1c914e091fb2> in <module>
----> 1 sa_session.table_names

AttributeError: 'scoped_session' object has no attribute 'table_names'

In [15]: engine.table_names()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-d72bc75a6b62> in <module>
----> 1 engine.table_names()

NameError: name 'engine' is not defined

In [16]: db_session.engine.table_names()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-16-0fac1ec2173e> in <module>
----> 1 db_session.engine.table_names()

NameError: name 'db_session' is not defined

In [17]: notification.id
Out[17]: 1

In [18]: notification.message_text

In [19]: notification.message_text = "Hello"

In [20]: notification.message_text
Out[20]: 'Hello'

In [21]: notification.create_time
Out[21]: datetime.datetime(2022, 7, 13, 10, 32, 9, 592546)

In [22]: user = User(email="test"+str(random_number)+"@test.com", password="abcde",username="notifi
    ...: cation_user"+str(random_number))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-22-626b602abb06> in <module>
----> 1 user = User(email="test"+str(random_number)+"@test.com", password="abcde",username="notification_user"+str(random_number))

NameError: name 'random_number' is not defined

In [23]: user = User(email="test"+str(11)+"@test.com", password="abcde",username="notification_user
    ...: "+str(11))

In [24]: sa_session.add(user)

In [25]: sa_session.flush()

In [26]: assert user.id
/Users/shivanisangwan/galaxy/.venv/bin/ipython:1: SAWarning: Dialect sqlite+pysqlite does *not* support Decimal objects natively, and SQLAlchemy must convert from floating point - rounding errors and other issues may occur. Please consider storing Decimal numbers as strings or integers on this platform for lossless storage.
  #!/Users/shivanisangwan/galaxy/.venv/bin/python

In [27]: user.id
Out[27]: 1

In [28]: una = UserNotificationAssociation()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-28-2ee2a0b556e0> in <module>
----> 1 una = UserNotificationAssociation()

TypeError: __init__() missing 2 required positional arguments: 'user' and 'notification'

In [29]: una = UserNotificationAssociation(user, notification)

In [30]: una.id

In [31]: una.user
Out[31]: <galaxy.model.User(1) at 0x111e5b748>

In [32]: una.user_id
Out[32]: 1

In [33]: una.notification
Out[33]: <galaxy.model.Notification(1) at 0x1111de630>

In [34]: una.notification.message_text
Out[34]: 'Hello'

In [35]: una.status_seen

In [36]: una.status_seen = True

In [37]: una.status_seen
Out[37]: True