veganism.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Veganism Social is a welcoming space on the internet for vegans to connect and engage with the broader decentralized social media community.

Administered by:

Server stats:

208
active users

#sqlmodel

0 posts0 participants0 posts today
dilawar<p>I am probably holding them wrong!</p><p>This time I tried writing a web app not in <a href="https://fosstodon.org/tags/php" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>php</span></a> but <a href="https://fosstodon.org/tags/fastapi" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>fastapi</span></a> + <a href="https://fosstodon.org/tags/sqlmodel" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>sqlmodel</span></a> (python) and <a href="https://fosstodon.org/tags/vue3" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>vue3</span></a> ( javascript). It kind of works well but refactoring is a nightmare. </p><p>In the beginning, it felt like I was having the best of both worlds -- Python and Vue3. Dev speed was good. Now maintaining and refactoring make me feel like I am having the worst of both worlds.</p><p>As a single dev, I should have stayed with <a href="https://fosstodon.org/tags/php" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>php</span></a>!</p>
Feoh<p>An interesting aspect of working with <a href="https://oldbytes.space/tags/sqlmodel" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>sqlmodel</span></a> - it has no concept of List as a type:</p><p><a href="https://github.com/fastapi/sqlmodel/issues/178" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/fastapi/sqlmodel/is</span><span class="invisible">sues/178</span></a></p><p>This is actually totally understandable because we're persisting to sql underneath, but I will admit it's a bit of an awkward feel.</p><p>I hit this in building my just-for-fun <a href="https://oldbytes.space/tags/Python" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Python</span></a>/#FastAPI/#SQLModel Multi-User-Dungeon.</p><p>I have a Location class that I'd wanted to look like this:</p> <p>import uuid<br>from typing import List<br>from sqlmodel import Field, SQLModel</p><p>class Location(SQLModel, table=True):<br> id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)<br> name: str = Field(unique=True)<br> description: str<br> exits: List[uuid.UUID] = []<br> players_here: List[uuid.UUID] = []</p> <p>But that's not gonna fly. I guess I'll need to create one class for player locations and another for exits per location. Something like:</p> <p>from sqlmodel import Field, SQLModel<br>import uuid</p><p>class PlayerLocation(SQLModel, table=True):<br> id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)<br> player: uuid.UUID = Field(unique=True)<br> location: uuid.UUID </p> <p>It doesn't feel particularly elegant and it'll require a teency bit more admin code but it'll work, and it's still a hell of a lot better than mucking about with Berkeley DB like the old school MUDs used to do :)</p>