davidism, to python
@davidism@mas.to avatar

Looking forward to SQLAlchemy 2.1 so I can do ForeignKey(lambda: Other.id) instead of ForeignKey("other.id"), and relationship(back_populates=lambda: Other.things). Last little bit needed to for (non-string) forward references that don't cause circular imports.

davidism, to python
@davidism@mas.to avatar

Just released Flask-Alembic 3.0! This extension combines Flask and Flask-SQLAlchemy with the Alembic migration library, providing CLI and programatic access to Alembic's functionality. It went 7.5 years without needing a release. This fixes compatibility with Flask-SQLAlchemy 3.1, and generally modernizes the project, tooling, and minimum requirements. https://github.com/davidism/flask-alembic/releases/tag/3.0.0

tedivm, to python
@tedivm@hachyderm.io avatar

I've got a sneak peak of my latest open source project: Paracelsus.

Long story short, I got sick of manually making database diagrams for SQLAlchemy. The data is all there, so why not generate the diagrams directly?

Paracelsus (named after the alchemist who wrote about mermaids) will read your database models and create diagrams in either Mermaid or Dot format. It can also be used to inject diagrams in markdown files as code blocks.

https://github.com/tedivm/paracelsus

scy, to python
@scy@chaos.social avatar

Instead of writing complicated try-catch constructs to things, using auto-retrying function certainly changed my life to the better.

This is using & the library https://pypi.org/project/backoff/ to retry generating a unique token, in the rare event that we chose a token that’s already in the database. On an IntegrityError, the function will “call itself” again.

(Event hooks & exponential backoff are available too.)

kushal, to python
@kushal@toots.dgplug.org avatar
sergi, to random
@sergi@floss.social avatar

This question has been in my head these past few days, so I finally decided to post it on the official support channels. If by any chance you know the answer, please let me know!

https://github.com/sqlalchemy/sqlalchemy/discussions/10392

commander, to random
pamelafox, to random
@pamelafox@fosstodon.org avatar

For a lil cheatsheet on upgrading to 2.0, check out the ORM migration guide: https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-orm-usage

davidism, to python
@davidism@mas.to avatar

Flask-SQLAlchemy 3.1.0 released, with support for SQLAlchemy 2's new annotation-based model definition. Thanks to @pamelafox for becoming a maintainer and enabling that support!
https://pypi.org/project/Flask-SQLAlchemy/3.1.0/
https://github.com/pallets-eco/flask-sqlalchemy/releases/tag/3.1.0

hwesta, to python
@hwesta@wandering.shop avatar

Question involving

Currently, we run end-to-end API tests against a sqlite DB, which takes about 2 seconds. I want to switch to postgres (what we use in prod) but that makes the tests take a lot longer, about 12 seconds.

Is there a way to improve this?

What might be causing the slowness? Where can I look? Is it networking to the docker container? Postgres enforcing constraints? Running flush after every DB fixture? Something else?

awws, to Astronomy

I've got this data-complex astronomy project I'm working on (pro-bono).

I have a number of different backends I pull from (NASA, Unis,. etc) all who use diff field names for the same thing resulting in lots of tedious (and future error-prone) data parsing and checking code.

Was hoping to use something like pydantic as an in-between translator/mapper of thediff fields to the same schema(s).

Anyone seen something like that?

lsmith, to python
@lsmith@mastodon.green avatar

any reading recommendations to optimize memory use of a dict containing lists which in turn contain lots of small dicts? once build up they can be read-only.

Stark9837,
@Stark9837@techhub.social avatar

@lsmith

In memory is also a good option. I like sqlite because there are great tools like which allows you to have features, but if it is simple I would just go with the built-in libraries to improve performance.

I also like sqlite with , as I have the simplicity of a sqlite database, but I can easily share it with containers with mounts and persist the data during development and production.

also has greay extensions for viewing sqlite databases, making it a glorified csv with advanced query capabilities.

scy, to random
@scy@chaos.social avatar

It seems to me that

a) the learning curve of resembles a sine wave and
b) it couldn't have a better name.

_alen, to python

At first, I didn’t like type hints in , but we decided to give it a go since our codebase really exploded in the last couple of years. All I can say now is we should have done it earlier. I still find it unbealivable that we discovered so many small bugs that went unnoticed all these years.

Stark9837,
@Stark9837@techhub.social avatar

@_alen

I am quite lazy with them and whoch they were more automatically detected, especially for diciotnaries. During development, my dictionaries often change, and I get lazy. Once my code base grows, it is very frustrating to have to go back!

But I have to say, with something liek . Their type hints really make development easier!

thumper, to python

Looking for suggestions, SQLAlchemy says:

Evaluating non-mapped column expression 'run_updates.run_id' onto ORM instances; this is a deprecated use case. Please make use of the actual mapped columns in ORM-evaluated UPDATE / DELETE expressions.

Gathering counts out of band and wanting to update counts of multiple rows at once.

x = Values(...).data(...)

then

update(Table).where(Table.field == x.c.field).values(field2 = Table.field2 + x.c.field2)

ideas?

Stark9837, to python
@Stark9837@techhub.social avatar

What is your favorite for and ? I am currently looking for an ORM judt to sinplify my implementation.

I am considering going for SQLite because the writes and reads are low, and the total size will also be a few 100 records, but I want the strengths of SQL. Also, I am running it in , so it simplifies the deployment.

I am looking at and also saw on .

This is the first time I am doing something like this. Normally, my data is simply printed to CSV files.

setebos,
@setebos@mastodon.online avatar

@Stark9837 for a small project it's not that important. both and will do the work for you. The limitation will be on the SQLite side

Stark9837,
@Stark9837@techhub.social avatar

@setebos

I am aware of the limitations, but I am far below them. I want to project to be easily deployable by others and then the usage will also be low enough for it to suffice.

feels a lot like the web-development that you get for and , but I like , the docs also seem good.

Stark9837,
@Stark9837@techhub.social avatar

@orsinium

I prefer to use something more popular, that the support is better. The docs of are a bit odd. I found myself getting stuck after the tutorial, like you said. It seems 2.0 documentation isn't the best with the new declarative style, but I found some other resources, and I am diving into code I found on to see how others did it.

is cool, but the names like that always turn me off. I need serious names for libraries I use, I don't know. But I can see that it had great influence from modern styles, so it might be better for people coming from that.

Thanks for the info!

Stark9837,
@Stark9837@techhub.social avatar

@orsinium

I haven't used async and wait with yet. So this will also be a fun way to get into it with . What I like about it is that I could also easily move away from if I need to, and has great support, so I would need to change much.

davidism, (edited ) to python
@davidism@mas.to avatar

I'm designing a library that provides a core set of functionality, then provides integrations with SQLAlchemy and Flask. Those specific integrations are the reason I wrote the library, but other integrations could be written around the same core, and core can be used without any integration. Should I split core and integrations into separate libraries?

Stark9837,
@Stark9837@techhub.social avatar

@dozymoe @davidism

To then install the version using ? That would be cool.

fredrikaverpil, to random
@fredrikaverpil@fosstodon.org avatar

Hoooooly moly, this blew my mind a little 🤯 🤩. You can use sqlc to generate the ORM, backed by models, from raw SQL 🥩 queries!

I threw together a demo here: https://github.com/fredrikaverpil/sqlc-python-demo

✋ Note that all this is in beta though.

fabian, to programming
@fabian@floss.social avatar

🔖 ormar
https://collerek.github.io/ormar/

Mini ORM for Python, with support for Postgres, MySQL, SQLite to be used with async frameworks

  • All
  • Subscribed
  • Moderated
  • Favorites
  • provamag3
  • kavyap
  • DreamBathrooms
  • cisconetworking
  • magazineikmin
  • InstantRegret
  • Durango
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • mdbf
  • khanakhh
  • tacticalgear
  • JUstTest
  • everett
  • modclub
  • Leos
  • cubers
  • ngwrru68w68
  • ethstaker
  • osvaldo12
  • GTA5RPClips
  • anitta
  • megavids
  • normalnudes
  • tester
  • lostlight
  • All magazines