Skip to content

Cant get demo to run #343

Open
Open

Description

@arminposchmann

Hi all,
i stumbled about this project when looking for a way to sort PysimpleGui Tables and have a headings marker for the sorting. Then i tried the version 2.3.0 of this project and could only get the Restaurant demo to run. All the Fruit examples fail with
Traceback (most recent call last):
File "/home/ap/pydev/testpy/testfiles/fruit4.py", line 20, in
ss.record(table, 'name', label='Fruit Name'), # pysimplesql.record() convenience function for easy record creation!
File "/home/ap/.local/lib/python3.10/site-packages/pysimplesql/pysimplesql.py", line 2392, in record
label_text = query_info.split('.')[1].replace('fk', '').replace('_', ' ').capitalize() + ':'
IndexError: list index out of range

Is there a way to get a demo that works with a sg.Table and is able to sort ?
I tried with PySimpleGUI 4.6.1 and with PySimpleGUI 5.0.3

Activity

  1. ssweber commented on Mar 26, 2024

    @ssweber
    Collaborator

    Could you download the latest master version? here's a link to download the zip

    I’m not actively working on this project, but left the master version in a good working state. All the SQLite examples should work.

  2. arminposchmann commented on Apr 3, 2024

    @arminposchmann
    Author

    Yes, after downloading and installing from git, most of what i am interested in is working.
    I managed to reskin everything with little extensions to psg_reskinner and most easy demos are running.
    What i'm interested in is transforming the data: set_transform(ss.simple_transform)
    There is a demo journal_with data_manipulation.py that shows exactly the transform i would like to use,
    but the demo fails on the requery call.
    See the output below:
    2024-04-03 17:48:34.561 | INFO | pysimplesql.pysimplesql:execute:10059 - Executing query: SELECT "Journal".* FROM "Journal" LEFT JOIN "Mood" ON "Journal"."mood_id"="Mood"."id" ORDER BY entry_date DESC None
    2024-04-03 17:48:34.562 | DEBUG | pysimplesql.pysimplesql:get_value:824 - Getting current record for Journal.id
    2024-04-03 17:48:34.563 | DEBUG | pysimplesql.pysimplesql:sort:3313 - Sort column is None. Resetting sort.
    2024-04-03 17:48:34.563 | DEBUG | pysimplesql.pysimplesql:set_by_pk:1997 - Setting table Journal record by primary key 1
    2024-04-03 17:48:34.563 | DEBUG | pysimplesql.pysimplesql:update_selectors:4675 - update_elements: SELECTOR FOUND
    2024-04-03 17:48:34.563 | DEBUG | pysimplesql.pysimplesql:update_selectors:4681 - <class 'pysimplesql.pysimplesql.LazyTable'>
    2024-04-03 17:48:34.563 | DEBUG | pysimplesql.pysimplesql:update_selectors:4725 - update_elements: Table selector found...
    2024-04-03 17:48:34.569 | DEBUG | pysimplesql.pysimplesql:get_value:824 - Getting current record for Journal.id
    2024-04-03 17:48:34.570 | DEBUG | pysimplesql.pysimplesql:update_selectors:4762 - Selector:: index:[0] found:True
    2024-04-03 17:48:34.572 | DEBUG | pysimplesql.pysimplesql:simple_transform:4995 - Transforming entry_date from 1712159314 to 04/03/24
    2024-04-03 17:48:34.575 | DEBUG | pysimplesql.pysimplesql:first:1639 - Moving to the first record of table Journal
    2024-04-03 17:48:34.575 | DEBUG | pysimplesql.pysimplesql:update_elements:4366 - update_elements(): Updating PySimpleGUI elements
    2024-04-03 17:48:34.575 | DEBUG | pysimplesql.pysimplesql:update_element_states:4893 - Updating element Journal.entry_date to disabled: False, visible: None
    2024-04-03 17:48:34.576 | DEBUG | pysimplesql.pysimplesql:update_element_states:4893 - Updating element Journal.mood_id to disabled: False, visible: None
    2024-04-03 17:48:34.576 | DEBUG | pysimplesql.pysimplesql:update_element_states:4893 - Updating element Journal.title to disabled: False, visible: None
    2024-04-03 17:48:34.576 | DEBUG | pysimplesql.pysimplesql:update_element_states:4893 - Updating element Journal.entry to disabled: False, visible: None
    Traceback (most recent call last):
    File "/home/ap/pydev/testpy/testfiles/sql/.journal_with_data_manipulation.py", line 74, in
    frm['Journal'].requery()
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 1584, in requery
    self.first(
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 1650, in first
    self.frm.update_elements(self.key)
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 4378, in update_elements
    self.update_actions(target_data_key)
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 4420, in update_actions
    or self[data_key].pk_is_virtual()
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 2727, in pk_is_virtual
    return bool(pk in self.virtual_pks)
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 2710, in virtual_pks
    return self.rows.attrs["virtual"]
    KeyError: 'virtual'

    Thank you for your answer. This project is very interesting!

    Regards Armin

  3. ssweber commented on Apr 4, 2024

    @ssweber
    Collaborator

    That shouldn’t be too difficult to fix. Looks like we assume “virtual” key is there when it isn’t. I’ll push a fix for that when I have a second

  4. ssweber commented on Apr 4, 2024

    @ssweber
    Collaborator

    See if master now works for you!

  5. arminposchmann commented on Apr 4, 2024

    @arminposchmann
    Author

    The stacktrace changed a little bit, but it does not work.

    INFO:pysimplesql.pysimplesql:Executing query: SELECT "Journal".* FROM "Journal" LEFT JOIN "Mood" ON "Journal"."mood_id"="Mood"."id" ORDER BY entry_date DESC None
    Traceback (most recent call last):
    File "/home/ap/pydev/testpy/testfiles/sql/pysimplesql/examples/SQLite_examples/journal_with_data_manipulation.py", line 74, in
    frm['Journal'].requery()
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 1583, in requery
    self.first(
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 1649, in first
    self.frm.update_elements(self.key)
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 4386, in update_elements
    self.update_selectors(target_data_key, omit_elements)
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 4741, in update_selectors
    values = dataset.table_values(
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 2788, in table_values
    if self.current.has_backup and not self.current.get().equals(
    File "/home/ap/pydev/pysimplesql/src/pysimplesql/pysimplesql.py", line 748, in has_backup
    isinstance(rows.attrs["row_backup"], pd.Series)
    KeyError: 'row_backup'

  6. ssweber commented on Apr 4, 2024

    @ssweber
    Collaborator

    Ah ok. Let me dig a little deeper and figure out where we arnt populating the attrs dictionary with (at least) empty values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions