Data Science and sql problem

17 views
Skip to first unread message

Prashant Singh

unread,
Jul 26, 2020, 12:00:42 PM7/26/20
to Django users
How can i connect database with help of function in jupyter notebook and then conver data into csv to build model ?

Gurmeet Kaur

unread,
Jul 26, 2020, 12:16:53 PM7/26/20
to django...@googlegroups.com
you could try using connection and cursor to connect nd then pandas to read csv using readcsv function

On Sun, Jul 26, 2020, 11:59 AM Prashant Singh <prashant...@gmail.com> wrote:
How can i connect database with help of function in jupyter notebook and then conver data into csv to build model ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dd90d45a-dfbf-47a6-86b2-a4e600d4a9c9n%40googlegroups.com.

Yamen Gamal Eldin

unread,
Jul 27, 2020, 12:37:44 AM7/27/20
to django...@googlegroups.com
Try sql alchemy, if you need a full access with many functionality. Other than that, u can connect directly to the database through python. The exact implementation will depend on the database type

AJ Wattoo

unread,
Jul 27, 2020, 5:25:52 AM7/27/20
to Django users
as far i understand you want to connect with postgreSQL database on jupyter notebook :
you can do like this
1. install -c anaconda psycopg2 and install -c anaconda sqlalchemy

2. from sqlalchemy import create_engine and import pandas as pd

3. engine=create_engine(‘postgres+psycopg2://postgres:0000@localhost:5432/anyname’)

In thes case postgres = name of my databse , 0000 is my password , localhost=host, port = 5432, anyname = database name

4. con = engine.connect()

5. df=pd.read_sql_query(SQL queries #whatever you want to get from database)

and then saving that data in csv 

6. df.to_csv('file_name.csv')

Integr@te System

unread,
Jul 27, 2020, 1:44:10 PM7/27/20
to django...@googlegroups.com
Hi Friend,

If you want more option, new t-sql with predict statement directly on db.



Reply all
Reply to author
Forward
0 new messages