Notes/2026-02-10.md

73 lines
2.5 KiB
Markdown

[Mardi 10 Février 2026]
# db Browser fir SQLite + fix grabber et serv local etc
django flask
1. [Commande du jour]
# uvicorn app:app --reload --host 0.0.0.0 --port 8000
The 500 Internal Server Error was caused by accessing ordi.hostname after the SQLAlchemy session was closed. Once session.close() is called, the Ordinateur instance becomes detached from the session, and accessing its attributes triggers a DetachedInstanceError because SQLAlchemy can't refresh the data.
I've moved the print statement to occur before session.close(), so the instance is still attached when accessing the attributes.
2. [Suite jsp]
ORM
Object Relationship Manager
------------
Interface utilisateur/api
-------------------------
ORM
-------------------------
SQL
app.py
(lancement de l'appli)
1/ Create_engine
2/ create_all
3/ create_session
4/ create_record
5/ session_commit
6/ session.close
grabber.sh -> /endpoint -> créer un ordi (-> qui est écrit dans la base de donnée)
statement = select(HEro).where(Hero.nam == "exemple-pc")
hero = session.exec(statement).first()
remplacer .first par .length() ?
-> sert à aller vérifier dans la base de donnée si l'ordinateur exemple-pc est déjà inscrit dans la base de donne pour ne pas créer un doublon
@app.get("/ordi/{ordi_id}"), response_class=HTMLResponse)
async def get_ordi1_info(request: REquest, ordi_id: int):
with Session(engine) as session:
statement = select(Ordinateur).where( Ordinateur.id == ordi_id )
this_ordi = session.exec(statement).first()
return templates.TemplateResponse(
request=request, name="ordi.html", context={"ordi": this_ordi}
SemVer
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes
MINOR version when you add functionality in a backward compatible manner
PATCH version when you make backward compatible bug fixes
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Semantic Versionning
0.0.1<-correction de bugs (chiffre de droite)
0.1.0<-nouvelles fonctionnalités (chiffre du milieu)
0.1.1<-correction de bug
0.2.O<-nouvelles fonctionalités / function
1.0.0<-stable release / breaking change (chiffre de gauche)
git add
git commit
git tag - v0.0.1 -m "version test"
git push --tags
# a faire/vérifier
page ordi(numéro)/delete qui supprime la page numérotée (bouton ?)
page /ordis qui répertories tout les pc enregistrés (actuellement juste / )
push avec semver