"python manage.py dbshell" for other DB Command-Line Clients (Django) - python

I read the documentation about "dbshell".
Then, it says:
Runs the command-line client for the database engine specified in your
ENGINE setting, with the connection parameters specified in your USER,
PASSWORD, etc., settings.
For PostgreSQL, this runs the psql command-line client.
For MySQL, this runs the mysql command-line client.
For SQLite, this runs the sqlite3 command-line client.
For Oracle, this runs the sqlplus command-line client.
So, as the documentation says, with the command below, it's possible to run(open) DB Command-Line Clients for PostgreSQL, MySQL, SQLite and Oracle:
python manage.py dbshell
My question:
With the command below, is it possible to run(open) DB Command-Line Clients for other databases such as MSSQL(SQL Server), MongoDB, etc?
python manage.py dbshell

No. At this moment (24th June, 2022) django doesn't support any other database backend. The source code has only backend for PostgreSQL, MySQL, SQLite and Oracle.
However, there is a MSSQL backend from Microsoft. It has all the bells and whistles.
For MongoDB, I haven't seen any backend that implemented client.py. You might want to request a feature to this project.

As far as I know, Yes, it's possible to run(open) the DB Command-Line Client for MSSQL(SQL Server) when connecting Django and MSSQL with mssql-django.
This is the MSSQL Command-Line Client as shown below:

Related

Is there a way to connect Python to an external sqlite3 database

I haven't been able to find any documentation regarding whether it's possible to access SQLITE3 (using Python) when the SQLITE database is hosted externally:
I have my SQLITE3 database hosted on my VPS (alongside some other stuff that doesn't really matter) - rather than having it as a local file with my Python program.
Therefore, is it possible for me to connect to the SQLITE database which is hosted on my VPS, or will the SQLITE DB have to be hosted locally for me to be able to do this?
The reason I want it to be accessible from my VPS is because I want to be able to run the program on multiple computers and them all have the same access to the database- if this isn't possible, are there any other options which would allow me to do this?
If you want to have a database server with external, possibly remote, applications interacting a client-server protocol switch to PostgreSQL, MariaDB, etc.
see: How to connect to SQLite3 database server?

How to configure Apache Airflow to work with MS SQL Server Windows Authentication

How do I connect MS SQL Server using Windows Authentication using Airflow Web UI or modifying existing SQLAlchemy/pymssql Python modules?
I have SQL Server SSIS packages which can't use this option https://joethebusinessintelligenceguy.wordpress.com/2013/08/14/ssis-2012-using-sql-authentication-with-dont-save-sensitive-successfully/) hence I'm trying to start the SSIS steps by using Windows Authentication.
I have found following links showing that support indeed exists but I don't know how to implement the same on Airflow -installation (which file to modify or where to create new conn_id).
How do I connect to SQL Server via sqlalchemy using Windows Authentication?
Connecting to MS SQL Server with Windows Authentication using Python?
https://www.mail-archive.com/sqlalchemy#googlegroups.com/msg13620.html
To use Windows Authentication, the Apache Airflow will need same windows access that your Sql Server, and that's strongly not recommended.
So probably is better use an User and Password to Connect your SqlDatabase.
Apache Airflow does it have an info in your documentation to make connections in SQL SERVER in this link

PostgreSQL multi user application

I want to know that if multi-users try to access same database for insert or retrieve data via my python program, do they all need to install PostgreSQL in their computers? How this process works?
If the database is located on another server, then no, clients don't have to install postgresql. They will need to install a postgresql adapter, like psycopg, so that python can communicate with the database, and most applications choose to use some type of ORM, like sqlalchemy, on top of the database adapter to make communication with the database more object-oriented and pythonic.
If you use psycopg2, it already comes with lipq DLL, the library used to communicate with PostgreSQL through TCP.
Actually, psycopg2 is a wrapper for libpq:
http://initd.org/psycopg/docs/
Therefore, you won't need to install PostgreSQL server binaries in the client workstations.

How to View My Postgres DB Schema from Command Line

So I have my Django app running and I just added South. I performed some migrations which worked fine locally, but I am seeing some database errors on my Heroku version. I'd like to view the current schema for my database both locally and on Heroku so I can compare and see exactly what is different. Is there an easy way to do this from the command line, or a better way to debug this?
From the command line you should be able to do heroku pg:psql to connect directly via PSQL to your database and from in there \dt will show you your tables and \d <tablename> will show you your table schema.
locally django provides a management command that will launch you into your db's shell.
python manage.py dbshell
django also provides a management command that will display the sql for any app you have configure in your project, regardless of the database manager (SQLite, MySQL, etc) that you're using:
python manage.py sqlall <app name>
Try it! It could be usefull!

Remote execution of commands using the Django ORM

Can I somehow work with remote databases (if they can do it) with the Django ORM?
It is understood that the sitting has spelled out the local database. And periodically to make connection to various external databases and perform any sort of commands such as load dump.
If you can connect to the database remotely, then you can simply specify its host/port in settings.py exactly as you would a local one.

Categories

Resources