0

I'm pretty new to Python, coming from Drupal and found that the abstraction layer made sense for me there, perhaps out of familiarity more than anything else. But what I like about Drupal is that there's one way to do something so it's easy to find consistent examples.

There's a lot I like about Python so far but because there are so many abstraction layers and the layers are really flexible, I find it difficult to find consistent examples.

I've given PyDal and SQLAlchemy a go so far. I found SQLAlchemy made a bit more sense but I'm having difficulty making a start with basic queries.

e.g. update person set name = 'Sally' where id = 1; I would expect to abstract something like:

db.update('person').where(id=1).values(name='Sally')

or

Person.where(id=1).set(name='Sally')

Where Person is a class defining the table.

There seem to be lots of examples of inserting but not updating or other common queries so it's difficult for me to find an abstraction layer that would suit me.

Does anyone know where there are a load of examples for each abstraction layer or even a page that makes a comparison of examples between each layer? Failing that, identifying which layer comes close to my above examples and give me an example or link would be really great.

Thank you!

1 Answer 1

1

So I just found the following stats about database abstraction layers. https://python.libhunt.com/categories/251-relational-databases

From that, Peewee seems the most popular. I had a look at the documentation and it seems clearer than PyDal and SQLAlchemy. I've had a quick play with it and Peewee seems to be what I'm looking for. I'm sure SQLAlchemy has its place but for me I don't need performance, I need quick and easy implementation which so far Peewee seems to provide. Will update if I switch to something else but at the moment Peewee is the one for me.

Sign up to request clarification or add additional context in comments.

1 Comment

So I've just found that SQLAlchemy can write a Dataframe to a database. It seems to be the only abstraction layer that is supported by Pandas. So potentially a big +1 for SQLAlchemy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.