How to migrate SQL data to NoSQL document? - python

I have a SQL database administrate with Django (web Framework). On this database, items are only update.
In other side, I have a NoSQL database (document-oriented). Sometimes, I need to migrate the SQL Data to NoSQL document forms and insert it on the NoSQL database.
I saw this question: Migrate data from relational DB to NoSQL
But the answer does not suit me.
And I saw Django-nonrel can help me to get a connector to a NoSQL database.
In my case, are there tools or any solutions more appropriate than create classes and methods in Python by myself for transform SQL data to NoSQL document?

Related

SQLAlchemy Postgresql database django

I am new to Django and have a question in regards to whether or not I have to re-enter data or can use existing data from a postgres database and apologize if this has been asked before.
I have a Postgres database in which I created with SQLAlchemy ORM. I use this database for data analysis and want to create a web app for the data presentation. I know that Django has its own modeling system and ORM, do I have to recreate the database from scratch since I created this with SQLAlchemy's ORM?
You can use inspectdb command from Django.
https://docs.djangoproject.com/en/4.0/howto/legacy-databases/

Customize the Django ContentTypes and AdminLog and Migration model

I am working on a Django project and it requires 3 different database servers with different engines like MySql, PostgreSQL and SQLite.
SQLite has all the client side setting table, tables with not shared data [app has a feature to not upload some data to the server] and configuration tables and it is on the client machine through a tweaked C# app to create a django server environment and show the django site in a browser control like a native application.
PostgreSQL has tables that can be accessed by different clients on the network and has different tables with values of shared data. They maintain integrity with SQLite data through ContentType.
Django provides the contentType table that is created in both SQLite and PostgreSQL. Due to heavy use of other database managing tables we require them to be in a MySQL database on a separate server. So it would be great to have django_content_types, django_admin_log and django_migration in that MySQL server.
ContentTypes table is also used a lot and it is difficult to maintain contentTypes form two different database tables so we require it to be in one separate one with values form both the databases. And when one goes there why not the other two: django_migration, django_admin_log.
Also there is requirement to store raw SQL DDL queries in the database to track changes outside of the Django ORM and so it makes sense to add rows to django_migration and a new column to store raw SQL queries.
Also, this is the last thing for sure, django_admin_log only logs admin-site changes and also lacks data in message columns when new row is added or deleted. We really require it to store the JSON of values added to the particular table when adding and when deleting, the instance [json format of row] to message column about the record deleted. And require it to log all transactions on instances of both the databases.
I am looking to [customize/extend/create my own and override] these models in a Django App to gain the above expected behavior and have a portable app to use it in future such projects.
Regards,
    Aagam Sheth

How to connect to existing SQLite DB using tortoise ORM?

I have existing SQLite DB with large data in it. I want to query the data asynchronously using tortoise ORM. How do I connect the database and query the data?
There is not magical tool. The inspectdb option in Aerich works for mysql.
You can create your models and read data from old sqlite db by driver and insert into new database.
The bulk_create method can improve the process time.

Use sqlite3 for prototyping in a flask app

I am creating the prototype for a webapp using flask,
flask-sqlalchemy and some toy sqlite3 database.
I am using sqlite3 databases just for development purposes, but ideally
I would like to use some different SQL database in production.
What I am finding hard to understand is how to use SQLalchemy and sqlite3 in a way that I won't have to rewrite my queries once I use the production database.
A silly example: in mysql I can get a list of all the databases available (whose names I use to populate a "drop menu") using "SHOW DATABASES ", but in sqlite I have to do this by listing all the files in a directory.
What is the best way to prototype a webapp using sqlite3, without having to rewrite all the queries after?

Use two databases in Django 1.5

I have a Django 1.5 application with a SQLite or MySQL database. At the local server I have an Oracle database which I typically connect to with a connection string
"TNS=TNS-name; UID=user; PWD=pwd;".
How is it possible to print data from the local Oracle database in my Django application? Actually, I want to transfer data from the Oracle database into my main SQLite/MySQL database. I've seen some tutorials how to use an Oracle database as main database source in a Django application, but I want to keep my main database source and just load some specific data from the Oracle database in a specific Django view.
Thank you.
I'm not quite sure if this is what you're looking for, but the Django Docs seem to do a good job explaining it (if I interpreted it correctly). In short, you need to add it to your list of databases in your settings file and create a router. The lookup chain for databases is detailed here.

Categories

Resources