Flask Form with snowflake connector - flask

I've built a simple form on a web page built with flask. But I am looking to take the user input and query a snowflake database with it (using the snowflake connector) and print the output for the user.
I've set up a .py with the snowflake.connector which works, but I'm a little new to all this so any help would be much appreciated!
FORM ---USER INPUT---SNOWFLAKE---OUTPUT

Related

How can i use influxdb in django project

i have some trouble about influxdb+django configurations.
Firstly let me summarize my situation. I have an influxdb which is already collecting data from endnode(sensors). Data is transfering by LoraWan technology. I can read that datas from terminal by writing flux queries so database is working without any problem.
Now my second phase of this project is visualizing that datas on an web page. I am using django framework for that i completed the frontend parts nearly. I looked on internet for the configurations for influxdb on django but i couldnt handle it. In django documentation page they are listed some databases like below:
Django officially supports the following databases:
PostgreSQL
MariaDB
MySQL
Oracle
SQLite
How will i use/configure and get data from my influxdb ? Is it possible ? What are the alternative solutions.
Sure, Django doesn't support InfluxDB for its usual models (authentication and what-have-you, and of course your own apps), but you can simply use the InfluxDB Python client library to make a query in a view and e.g. return JSON data.
Adapting from the readme, you might have a view like
from influxdb_client import InfluxDBClient
client = InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org")
def get_data(request):
bucket = "my-bucket"
query_api = client.query_api()
result = query_api.query_csv('from(bucket:"my-bucket") |> range(start: -10m)')
return JSONResponse(result)

Integrating django-import-export with react

I have a postgresql database and I want to add data to it.
I want to upload an excel file containing the data and save it to database.
I have a backend server of django and a frontend server of React.
I am easily able to import the data from the excel sheet to database using django_import_export but from the django admin.
What I want is, to do this using React and for normal users(non superusers) also. Is there a way to integrate django_import_export with react? Any other way to implement this functionality is also apreciated.
Presumably your backend uses a REST API to handle requests from the frontend. So, you can write an API handler which receives the Excel data posted to it.
The Django API handler can create an import process to handle upload. Check the documentation for more information.
Note that if you are loading large files, then you might want to handle the upload asychronously. This is little more tricky, but you could look at Celery to help with this.

Migration from Wordpress to Django?

I created a website through Wordpress but now i want to migrate my site into Django without losses my data.
So, How can i switch my website from Wordpress to Django?
Should be pretty easy. Once you've designed and built your Django app and it's functioning correctly, write a Python script that accesses all the necessary data form your WP database and creates the corresponding Django objects.
If you're not an experienced programmer this will be extremely hard, unfortunately. But you'll learn a lot.
The hardest thing is rewrite worpress template to django template engine. I dont see nothing else than manual facture
The database schema of the wordpress website may differ from the Django website that you have created. To migrate all the data from Wordpress to Django, you first need to export the page details in the XML file from the Wordpress dashboard > Tool > Export section.
After exporting the data XML file you can write a Python script that read from the XML file and populate the current Django database.

Django: Saving oauth provider data

I set up a simple django site using django-allauth.
I created some oauth providers in the database.
Everything is fine and working on my laptop now.
I would like to store the created database tables somehow.
Use case: I want to set up a new development environments on a different PC painlessly.
How to store the initial data of django_allauth, so that after checking out the app from git the command manage.py migrate is all I need to have the relevant database tables filled?
Django_allauth already save those data to the database, you will find them in a table *_SocialApp, here is the model code from django_auth source

Django angular database form integration

I am currently trying a few ways of connecting a postgre sql database that I already have defined using a django model with a front end angular form that I created within the same project. (This a a django project using a little bit angular js)
So basically I have a form which accepts data from a user, and the data needs to be stored in one of the tables of the postgre sql database that I already created.
I was following this but there are many points that are unclear to me. Is there a better way to solve this?