How to create basic CRUD functionality in python given database tables

I want to develop a desktop application using python with basic crud operation. Is there any library in python that can generate code for CRUD functions and UI given a database table.

+2


source to share


3 answers


Hopefully this won't be the best option you end up with, but in the tradition of using web interfaces for desktop applications, you can always try django . I would specifically consider a command inspectdb

that will generate the ORM code for you.

The advantage is that it doesn't take a lot of code to get off the ground, and if you just want to use it from the desktop, you don't need a web server; you can use the provided test server. The linked admin site is easy to get off the ground and flexible to a certain point; past which people seem to invest a lot of time fighting it (probably a testament to how useful it is in the first place).



There are many drawbacks, not the least of which is the ability to use html / javascript / css when you want to start customizing a lot.

+3


source


If it were me, I would consider borrowing the django ORM, but again, I'm already familiar with it.

Having said that, I love working with it, it can be used out of scope and it will provide you with mysql, postgres or sqlite support. You can also connect django admin site to your models and have a web editor.



There are, of course, other ORMs and code generators (I hope some python gurus point out some of them, I'm a little curious).

0


source


If you want something really small and simple, I love Autumn ORM.

If you are using Django ORM, you can use Django's auto-generated admin interface, which is very nice. It is basically a web interface for viewing and editing records in your database.

If you think you need advanced SQL features, SQLAlchemy is a good way to go. I suspect that Django or Autumn is better for a desktop application.

There are other Python ORMs like Storm. Do a google search on "ORM python". See also the discussion on this website: What are some good ORM solutions for Python?

0


source







All Articles