fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

10K
active users

Recommend me a persistence strategy for my #python online game. I would like to spend as little time as possible writing DB cruft, and keep as much of that code out of my game classes as I can. #gamedev

@justindz You can use SQLite? AWS S3 can also be used as a small database with creative use of partitions.

@RethinkJeff I didn't phrase my question very well. I think I'm looking more for the python approach (e.g. ORM/ODM) than the actual repository. Pretty comfortable with SQLite, Mongo, etc.

gram

@justindz @RethinkJeff Most people use as but it can be hard to grasp sometimes. There are many ways to do the same thing and the documentation is a mess. Still, I don't know other alternatives with as good support for async and typing. Plus, it's popularity means lots of tutorials.

If you still want to try alternatives, I listed some of them here:
t.me/itgram_channel/581

TelegramITGramA week ago, SQLAlchemy 2.0.0 was released. Now, the default way to describe ORM models is using declarative type-annotations based definitions. So, the fields instead of id = Column(Integer) can be described as just id: int. In some cases, it can get more verbose, but it pays back by better IDE integration, syntax highlighting, type checking, and other cool stuff that comes with type annotations. I wanted to try different alternative ORMs with asyncio and typing support, but never got to it. Now I think that it gets quite hard to beat SQLAlchemy. The project, despite being very old, still keeps up the pace (what I can't say about Django ORM, Pony ORM, or Peewee) and has very good support for modern practice. Namely, for asyncio and type annotations. Anyway, there are some asyncio-powered ORMs that I haven't tried but that look interesting: + sqlmodel is a thin wrapper on top of pydantic and sqlalchemy from the author of FastAPI. It's not actively maintained but there is not that much of code for it to be a…

With sqlalchemy, be careful of using the model instances outside sqlalchemy orm sessions.
This is the first thing you need to check if you chose sqlalchemy orm.

@orsinium @justindz @RethinkJeff

@dozymoe @justindz @RethinkJeff I'm afraid if we try listing here all sqlalchemy gotchas and things you can do but shouldn't, we end up with a small book 👀

It's a big gotcha because of how it was unexpected.

@orsinium @justindz @RethinkJeff