I want to setup fastapi-admin with sqlalchemy orm.
I googled but got articles for fastapi-admin with tortoise orm only.
Can we set up it using sqlalchemy becuse its supports polymorphic association.
Or any other solution for the same that how can we create a app using fastapi and sqlalchemy with any admin panel also.
SQLAlchemy Admin provides admin functionalities like the fastapi-admin or flask-admin backend panel. It was released just recently in January 2022, so I'm not sure if it already has feature parity.
The missing sqlalchemy admin panel for fastapi was the reason why I didn't migrate from flask to fastapi, but with the new SQLAlchemy-Admin I give it a try.
Related
I am new to Django, and I was given a complete MySQL database with all relations and tables set. I am trying to put this data from MySQL database into my admin site.
I want to know if there is any other way to retrieve data from MySQL database without using Django models.
MySQL Database
MySQL database
I tried to use autogenerated model, but it did not work for me. Data doesn't show up in the admin site. (P.S. I do not necessarily require data to be in admin site, I am just trying to use it any ways possible)
Auto-generated model by django
python manage.py inspectdb > models.py
admin.py
from django.contrib import admin
# Register your models here.
from .models import Ligand
admin.site.register(Ligand)
Please, let me know if you know any ways to use data from MySQL database that was not created using Django model.
Thanks in advance
python manage.py inspectdb can be run to detect and generate models. More on it here: https://docs.djangoproject.com/en/2.2/howto/legacy-databases/
Our company is in the process of migrating our Google App Engine website's data from Google Cloud Datastore to mysql (CloudSQL to be precise)
I have written all the conversion routines to copy all of the current data entity tables from datastore to mysql and I am at the point where the code in our repos needs rewriting to interact with mysql instead of datastore.
Pretty much all of the current datastore entities subclass ndb.Model apart from one key table, our User entities which subclass from webapp2_extras.appengine.auth.models.User.
Subclassing from this does a lot of nice things behind the scenes such as setting up Unique and UserToken entries as well as setting up and taking care of sessions, setting them up when a user logs in and destroying them when a user logs out.
Now that the user table will live in mysql all these niceties that datastore was providing will need implementing separately and I am at a loss where to start.
What would be the best way to achieve this?
The site uses Google App Engine Standard Environment using the Python 2.7 runtime with webapp2 framework. I am using SqlAlchemy to interact with the mysql instance in the backend.
Any help or advice on this would be greatly appreciated and please let me know if you need any further specifics.
Searching around the webapp2 docs I found this information.
http://webapp2.readthedocs.io/en/latest/tutorials/auth.html#login-with-sessions
I did a little poking in the google SDK to see the same interface methods setup within webapp2_extras.appengine.auth.models.User.
I created an AuthModel interface with the basic properties webapp2 would need to create a session and I implemented the methods described on the page. The methods call the SqlAlchemy query which would in turn interact with the SqlAlchemy User class I had set up and allow me to return the parameters needed for webapp2 and GAE to do the rest.
I am thinking of creating a project for which I chose 2 python frameworks, django and falcon. I will be using Falcon to build APIs and Django for other operations.I don't understand, how to manage database operations in both the frameworks which will be accessing single database(mysql database).
My plan is to create tables using Django models into the database, but how about accessing the database values in falcon. I am not much aware about sqlalchemy. Thanks in advance.
If you're dead-set on trying to access Django models from Falcon then this does look possible.
Apparently as long as your Django app's code is present wherever your Falcon app is, it looks like that you could use it as described in this question here:
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
django.setup()
from yourdjangoapp.things import *
I'm relatively new to application development but here goes nothing.
I've been working on a project that employs the use of a Tornado server and SQLAlchemy's ORM for database management/access (using postgres in the back end).
At the outset of the project I hadn't considered the possibility that using SQLAlchemy would prevent me from taking advantage of Tornado's async features (since SQLAlchemy's database calls apparently 'block' the thread).
Do you have any suggestions as to how to implement an async-compatible setup with Tornado+SQLA+postgres?
Take a look at aiopg - https://github.com/aio-libs/aiopg
It is a Python 3.4 asyncio adapter for postgres that includes sqlalchemy support. I haven't tried it myself yet, but found it while looking for async libraries for postgres and tornado. I am using Momoko, but it only supplies the raw psycopg2 layer.
Remember that the latest version of Tornado supports asyncio, so asyncio libraries will now work with Tornado.
I am building a django application. Using SQLAlchemy as ORM for saving data like purchase order for the user . However want to use django ORM for the session middleware.
Is it a bad design decision to use both of these ORM components ?
If I should use only one ORM , which one I should use.
Thanks
J
If you're going with Django, you probably chose it because you feel it gives you more of what's needed for your project than the other Python web frameworks. If you use SQLAlchemy with Django, you're losing a lot of what Django gives you (e.g. tie-in with the forms library, the large collection of django apps, etc.)
Also, I wouldn't recommend using both. It's not something that would be impossible, but I just don't see the advantage to forcing yourself to go back and forth between two completely different APIs to be doing the same thing.
I've had no issues using both. I use Django's model for handling session data and user authentication, and SQLAlchemy for the database my application uses.
I find SQLAlchemy is easier to work with. However:
You can't easily manage security / user groups for your SQlAlchemy objects. (Use Django for those components)
I wouldn't recommend having SQLAlchemy and Django to access the same tables, it's better off with one ORM.
Otherwise - if your SQLAlchemy tables are separate from Django, and aren't required for security, form generation, or accessing Django tables directly, then it works great. I don't use Django's forms, and so most everything except for my session & user data is in SQLAlchemy.
If you had to use only one, use the Django ORM, because otherwise you lose out on a lot of features built into Django, and you might as well go with another framework like pylons.