How to train AI for Jam.py app from scratch

86 views
Skip to first unread message

Dean D. Babic

unread,
May 23, 2025, 6:11:27 AM5/23/25
to Jam.py Users Mailing List
https://chatgpt.com/share/683044b4-974c-8012-a0fc-61c664accecd

You should be able to start working on logic with this first steps..

See this for fields examples (for v5 but u get the idea)::
https://jampy-docs-v7.readthedocs.io/en/latest/intro/admin.html

Enjoy

D.

Dean D. Babic

unread,
May 23, 2025, 6:21:37 AM5/23/25
to Jam.py Users Mailing List
Here is the start of the App:
ai_train_jampy.PNG

There are no fields yet for any of the tables above. Or Primary keys - as it missed it!
The logic is similar for SYS_FIELDS. Just look at the above diagram and an EMPTY 
admin.sqlite database, which we get from jam-project.py script. Then look the DEMO
admin.sqlite for SYS fields.

Next is to tell AI to use admin.sqlite from python script which contains INSERT sql.

The help from other are welcomed. Pls do share.

Dean D. Babic

unread,
May 23, 2025, 10:08:42 AM5/23/25
to Jam.py Users Mailing List
Here is what AI learned. Use with:
jam-project.py
python ai1.py schema.sql
./server.py

The app will use demo.sqlite as DB (copy it here), and English lang:
ai01_train_jampy.png

The conclusion for now is that with AI we can produce Python script to read DB schema
and provide initial App tables names. With Captions and JS variables.
We could also use Import tables tho :) But lets see if we can automate.

If we can, we can potentially build an app in seconds.
ai1.py
schema.sql

Dean D. Babic

unread,
May 26, 2025, 3:06:07 AM5/26/25
to Jam.py Users Mailing List
Here is the AI constructing FIELDS from the python script:

https://chatgpt.com/share/68340f5a-77c0-8012-86b2-214d449347b5

python ai2.py schema.sql
Inserted field_id=15 table=DEMO_CUSTOMERS column=FIRSTNAME f_field_name=firstname f_data_type=1
Inserted field_id=16 table=DEMO_CUSTOMERS column=LASTNAME f_field_name=lastname f_data_type=1
Inserted field_id=17 table=DEMO_CUSTOMERS column=COMPANY f_field_name=company f_data_type=1
Inserted field_id=18 table=DEMO_CUSTOMERS column=ADDRESS f_field_name=address f_data_type=1
Inserted field_id=19 table=DEMO_CUSTOMERS column=CITY f_field_name=city f_data_type=1
Inserted field_id=20 table=DEMO_CUSTOMERS column=STATE f_field_name=state f_data_type=1
Inserted field_id=21 table=DEMO_CUSTOMERS column=COUNTRY f_field_name=country f_data_type=1
Inserted field_id=22 table=DEMO_CUSTOMERS column=POSTALCODE f_field_name=postalcode f_data_type=1
Inserted field_id=23 table=DEMO_CUSTOMERS column=PHONE f_field_name=phone f_data_type=1
Inserted field_id=24 table=DEMO_CUSTOMERS column=FAX f_field_name=fax f_data_type=1
Inserted field_id=25 table=DEMO_CUSTOMERS column=EMAIL f_field_name=email f_data_type=1
Inserted field_id=26 table=DEMO_CUSTOMERS column=SUPPORT_REP_ID f_field_name=supportRepId f_data_type=2
Inserted field_id=27 table=DEMO_CUSTOMERS column=PHOTO f_field_name=photo f_data_type=1
Inserted field_id=28 table=DEMO_CUSTOMERS column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=29 table=DEMO_ALBUMS column=TITLE f_field_name=title f_data_type=1
Inserted field_id=30 table=DEMO_ALBUMS column=ARTIST f_field_name=artist f_data_type=2
Inserted field_id=31 table=DEMO_ALBUMS column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=32 table=DEMO_GENRES column=NAME f_field_name=name f_data_type=1
Inserted field_id=33 table=DEMO_GENRES column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=34 table=DEMO_ARTISTS column=NAME f_field_name=name f_data_type=1
Inserted field_id=35 table=DEMO_ARTISTS column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=36 table=DEMO_TRACKS column=NAME f_field_name=name f_data_type=1
Inserted field_id=37 table=DEMO_TRACKS column=ALBUM f_field_name=album f_data_type=2
Inserted field_id=38 table=DEMO_TRACKS column=MEDIA_TYPE f_field_name=mediaType f_data_type=2
Inserted field_id=39 table=DEMO_TRACKS column=GENRE f_field_name=genre f_data_type=2
Inserted field_id=40 table=DEMO_TRACKS column=COMPOSER f_field_name=composer f_data_type=1
Inserted field_id=41 table=DEMO_TRACKS column=MILLISECONDS f_field_name=milliseconds f_data_type=2
Inserted field_id=42 table=DEMO_TRACKS column=BYTES f_field_name=bytes f_data_type=2
Inserted field_id=43 table=DEMO_TRACKS column=UNITPRICE f_field_name=unitprice f_data_type=4
Inserted field_id=44 table=DEMO_TRACKS column=FILE f_field_name=file f_data_type=1
Inserted field_id=45 table=DEMO_TRACKS column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=46 table=DEMO_TRACKS column=LOCKED f_field_name=locked f_data_type=2
Inserted field_id=47 table=DEMO_INVOICE_TABLE column=TRACK f_field_name=track f_data_type=2
Inserted field_id=48 table=DEMO_INVOICE_TABLE column=QUANTITY f_field_name=quantity f_data_type=2
Inserted field_id=49 table=DEMO_INVOICE_TABLE column=UNITPRICE f_field_name=unitprice f_data_type=4
Inserted field_id=50 table=DEMO_INVOICE_TABLE column=AMOUNT f_field_name=amount f_data_type=4
Inserted field_id=51 table=DEMO_INVOICE_TABLE column=TAX f_field_name=tax f_data_type=4
Inserted field_id=52 table=DEMO_INVOICE_TABLE column=TOTAL f_field_name=total f_data_type=4
Inserted field_id=53 table=DEMO_INVOICE_TABLE column=INVOICE f_field_name=invoice f_data_type=2
Inserted field_id=54 table=DEMO_INVOICE_TABLE column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=55 table=DEMO_INVOICE_TABLE column=PAID f_field_name=paid f_data_type=2
Inserted field_id=56 table=DEMO_HISTORY column=ITEM_ID f_field_name=itemId f_data_type=2
Inserted field_id=57 table=DEMO_HISTORY column=ITEM_REC_ID f_field_name=itemRecId f_data_type=2
Inserted field_id=58 table=DEMO_HISTORY column=OPERATION f_field_name=operation f_data_type=2
Inserted field_id=59 table=DEMO_HISTORY column=CHANGES f_field_name=changes f_data_type=1
Inserted field_id=60 table=DEMO_HISTORY column=USER f_field_name=user f_data_type=1
Inserted field_id=61 table=DEMO_HISTORY column=DATE f_field_name=date f_data_type=5
Inserted field_id=62 table=DEMO_INVOICES column=CUSTOMER f_field_name=customer f_data_type=2
Inserted field_id=63 table=DEMO_INVOICES column=INVOICE_DATE f_field_name=invoiceDate f_data_type=5
Inserted field_id=64 table=DEMO_INVOICES column=SUBTOTAL f_field_name=subtotal f_data_type=4
Inserted field_id=65 table=DEMO_INVOICES column=TAXRATE f_field_name=taxrate f_data_type=4
Inserted field_id=66 table=DEMO_INVOICES column=TAX f_field_name=tax f_data_type=4
Inserted field_id=67 table=DEMO_INVOICES column=TOTAL f_field_name=total f_data_type=4
Inserted field_id=68 table=DEMO_INVOICES column=PAID f_field_name=paid f_data_type=2
Inserted field_id=69 table=DEMO_INVOICES column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=70 table=DEMO_TEST column=RECORD_VERSION f_field_name=recordVersion f_data_type=2
Inserted field_id=71 table=DEMO_TEST column=TEST f_field_name=test f_data_type=1

Done. Inserted 57 fields into SYS_FIELDS.

So now that we have fields, we need to update OWNER_REC_ID for SYS_FIELDS from the previous run for  SYS_ITEMS with the ID for each table. Ie, Demo Customers ID=10.
We also need to update SYS_ITEMS with the F_PRIMARY_KEY....

Dean D. Babic

unread,
May 27, 2025, 1:22:40 AM5/27/25
to Jam.py Users Mailing List
Here is the final chat:

https://chatgpt.com/share/68340f5a-77c0-8012-86b2-214d449347b5

It produced the complete Jam.py app only by reading database SQL schema:

python ai5.py schema.sql
[SYS_ITEMS] Inserted DEMO_CUSTOMERS as id=6
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=15)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=16)
  ↳ [SYS_FIELDS] Field FIRSTNAME -> firstname (type=1, id=17)
  ↳ [SYS_FIELDS] Field LASTNAME -> lastname (type=1, id=18)
  ↳ [SYS_FIELDS] Field COMPANY -> company (type=1, id=19)
  ↳ [SYS_FIELDS] Field ADDRESS -> address (type=1, id=20)
  ↳ [SYS_FIELDS] Field CITY -> city (type=1, id=21)
  ↳ [SYS_FIELDS] Field STATE -> state (type=1, id=22)
  ↳ [SYS_FIELDS] Field COUNTRY -> country (type=1, id=23)
  ↳ [SYS_FIELDS] Field POSTALCODE -> postalcode (type=1, id=24)
  ↳ [SYS_FIELDS] Field PHONE -> phone (type=1, id=25)
  ↳ [SYS_FIELDS] Field FAX -> fax (type=1, id=26)
  ↳ [SYS_FIELDS] Field EMAIL -> email (type=1, id=27)
  ↳ [SYS_FIELDS] Field SUPPORT_REP_ID -> supportRepId (type=2, id=28)
  ↳ [SYS_FIELDS] Field PHOTO -> photo (type=1, id=29)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=30)
[SYS_ITEMS] Inserted DEMO_ALBUMS as id=7
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=31)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=32)
  ↳ [SYS_FIELDS] Field TITLE -> title (type=1, id=33)
  ↳ [SYS_FIELDS] Field ARTIST -> artist (type=2, id=34)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=35)
[SYS_ITEMS] Inserted DEMO_GENRES as id=8
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=36)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=37)
  ↳ [SYS_FIELDS] Field NAME -> name (type=1, id=38)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=39)
[SYS_ITEMS] Inserted DEMO_ARTISTS as id=9
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=40)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=41)
  ↳ [SYS_FIELDS] Field NAME -> name (type=1, id=42)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=43)
[SYS_ITEMS] Inserted DEMO_TRACKS as id=10
  ↳ [SYS_FIELDS] Field NAME -> name (type=1, id=44)
  ↳ [SYS_FIELDS] Field ALBUM -> album (type=2, id=45)
  ↳ [SYS_FIELDS] Field MEDIA_TYPE -> mediaType (type=2, id=46)
  ↳ [SYS_FIELDS] Field GENRE -> genre (type=2, id=47)
  ↳ [SYS_FIELDS] Field COMPOSER -> composer (type=1, id=48)
  ↳ [SYS_FIELDS] Field MILLISECONDS -> milliseconds (type=2, id=49)
  ↳ [SYS_FIELDS] Field BYTES -> bytes (type=2, id=50)
  ↳ [SYS_FIELDS] Field UNITPRICE -> unitprice (type=4, id=51)
  ↳ [SYS_FIELDS] Field FILE -> file (type=1, id=52)
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=53)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=54)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=55)
[SYS_ITEMS] Inserted DEMO_INVOICE_TABLE as id=11
  ↳ [SYS_FIELDS] Field TRACK -> track (type=2, id=56)
  ↳ [SYS_FIELDS] Field QUANTITY -> quantity (type=2, id=57)
  ↳ [SYS_FIELDS] Field UNITPRICE -> unitprice (type=4, id=58)
  ↳ [SYS_FIELDS] Field AMOUNT -> amount (type=4, id=59)
  ↳ [SYS_FIELDS] Field TAX -> tax (type=4, id=60)
  ↳ [SYS_FIELDS] Field TOTAL -> total (type=4, id=61)
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=62)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=63)
  ↳ [SYS_FIELDS] Field INVOICE -> invoice (type=2, id=64)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=65)
  ↳ [SYS_FIELDS] Field PAID -> paid (type=2, id=66)
[SYS_ITEMS] Inserted DEMO_INVOICES as id=12
  ↳ [SYS_FIELDS] Field CUSTOMER -> customer (type=2, id=67)
  ↳ [SYS_FIELDS] Field INVOICE_DATE -> invoiceDate (type=5, id=68)
  ↳ [SYS_FIELDS] Field SUBTOTAL -> subtotal (type=4, id=69)
  ↳ [SYS_FIELDS] Field TAXRATE -> taxrate (type=4, id=70)
  ↳ [SYS_FIELDS] Field TAX -> tax (type=4, id=71)
  ↳ [SYS_FIELDS] Field TOTAL -> total (type=4, id=72)
  ↳ [SYS_FIELDS] Field ID -> id (type=2, id=73)
  ↳ [SYS_FIELDS] Field DELETED -> deleted (type=2, id=74)
  ↳ [SYS_FIELDS] Field PAID -> paid (type=2, id=75)
  ↳ [SYS_FIELDS] Field RECORD_VERSION -> recordVersion (type=2, id=76)

✅ Done. Inserted 7 items and 62 fields.

ai_train_05_jampy.png

Here is the single script with updated info for SYS_PARAMS and SYS_TASKS  to use English, sqlite, and
demo.sqlite database for the new project. We can manipulate this so suit.

Now we need to tell AI to form the JSON file, which goes to table SYS_ITEMS field F_INFO for each table.
Since right now, what we will get is empty form.
ai_train_06_jampy.png

However, this is now really about how would you like to show the Forms and Views.
Are TABS going to be used, or BANDS? Not sure why would we need AI for this, but if we
want to impress someone, that's needed...
Will leave this to others.

As per ChatGPT:
"This gives you a fully scriptable way to bootstrap a Jam.py application from any existing database schema - a powerful starting point for automation or migrations."

Now

Enjoy
ai5.py

Dean D. Babic

unread,
May 28, 2025, 4:28:06 AM5/28/25
to Jam.py Users Mailing List
And finally:
https://chatgpt.com/share/6836c66e-f3f4-8012-9dcb-e09a5f290ee3

Fully functional app with Edit Forms etc from simple SQL schema.

ChatGPT did it all. 

We can now turn the lights off, close the shop, and throw the keys...

But wait! Is that all? Of course not. We can also build the lookups.
Maybe. Probably. Or can't bother since no one is interested anyway.

ai_train_07_jampy.png

Enjoy
ai6.py

Harshavardhan Patil

unread,
Jun 1, 2025, 2:59:21 AM6/1/25
to Jam.py Users Mailing List
Great Work Dean !!

Dean D. Babic

unread,
Jun 4, 2025, 2:50:39 AM6/4/25
to Jam.py Users Mailing List
Thanks

I am now hitting formatting issue with DB schema. So this:
CREATE TABLE vendors(guid text(32) PRIMARY KEY NOT NULL, name text(2048) NOT NULL, id text(2048) NOT NULL, notes text(2048) NOT NULL, currency text(32) NOT NULL, active integer NOT NULL, tax_override integer NOT NULL, addr_name text(1024), addr_addr1 text(1024), addr_addr2 text(1024), addr_addr3 text(1024), addr_addr4 text(1024), addr_phone text(128), addr_fax text(128), addr_email text(256), terms text(32), tax_inc text(2048), tax_table text(32));

is not the same as nicely formatted schema:
CREATE TABLE IF NOT EXISTS "DEMO_INVOICES"
(
"CUSTOMER" INTEGER,
"INVOICE_DATE" TEXT,
"SUBTOTAL" REAL DEFAULT 0,
"TAXRATE" REAL DEFAULT 5,
"TAX" REAL,
"TOTAL" REAL,
"ID" INTEGER PRIMARY KEY,
"DELETED" INTEGER,
"PAID" INTEGER DEFAULT 0,
"RECORD_VERSION" INTEGER
);

AI fixed it all. Here is the new script. Now it contains reserved words as well.
So "active" should change to JS "active_f", etc.

And with this cript, I've just built GnuCash app in few seconds....


ai7.py

Dean D. Babic

unread,
Jun 4, 2025, 3:20:59 AM6/4/25
to Jam.py Users Mailing List
Fixed ID's:
https://chatgpt.com/share/6836c66e-f3f4-8012-9dcb-e09a5f290ee3

Here is a fixed file which is now parsing correct Primary Keys.


ai8.py
Reply all
Reply to author
Forward
0 new messages