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
Like PySimpleGUI™, pySimpleSQL supports subscript notation, so your code can access the data easily in the format of db['Table']['field'].
144
+
Like PySimpleGUI™, pySimpleSQL supports subscript notation, so your code can access the data easily in the format of db['Table']['column'].
140
145
In the example above, you could get the current item selection with the following code:
141
146
```python
142
147
selected_restaurant=db['Restaurant']['name']
@@ -147,15 +152,15 @@ or via the PySimpleGUI™ control elements with the following:
147
152
selected_restaurant=win['Restaurant.name']
148
153
selected_item=win['Item.name']
149
154
```
150
-
### Any Questions? It's that simple.
155
+
### It really is that simple. All of the heavy lifting is done in the background!
151
156
152
157
To get the best possible experience with PySimpleSQL, the magic is in the schema of the database.
153
158
The automatic functionality of PySimpleSQL relies on just a couple of things:
154
-
- foreign key constraints on the database tables (lets PySimpleSQL know what the relationships are)
159
+
- foreign key constraints on the database tables (lets PySimpleSQL know what the relationships are, though manual relationship mapping is also available)
155
160
- a CASCADE ON UPDATE constraint on any tables that should automatically refresh child tables when parent tables are
156
-
refreshed
161
+
changed
157
162
- PySimpleGUI™ control keys need to be named {table}.{field} for automatic mapping. Of course, manual mapping is
158
-
supported as well. @Database.record() is a convenience function/"custom control" to make adding records quick and easy!
163
+
supported as well. @Database.record() is a convenience function/"custom element" to make adding records quick and easy!
159
164
- The field 'name', (or the 2nd column of the database in the absence of a 'name' column) is what will display in
160
165
comboxes for foreign key relationships. Of course, this can be changed manually if needed, but truly the simplictiy of
161
166
PySimpleSQL is in having everything happen automatically!
@@ -184,8 +189,8 @@ CREATE TABLE "Chapter"(
184
189
185
190
### But wait, there's more!
186
191
The above is literally all you have to know for working with simple and even moderate databases. However, there is a
187
-
lot of power in learning what is going on under the hood! Starting with the fully automatic example above, we will work
188
-
backwards to explain what is available to you for more control at a lower level.
192
+
lot of power in learning what is going on under the hood. Starting with the fully automatic example above, we will work
193
+
backwards and unravel things to explain what is available to you for more control at a lower level.
189
194
190
195
#### PySimpleSQL elements:
191
196
Referencing the example above, look at the following:
@@ -197,11 +202,11 @@ ss.record('Restaurant', 'name') # Table name, field name parameters
0 commit comments