Create a SQL table from a Pandas DataFrame

0 votes

Hi Guys,

I have one Pandas DataFrame in my Jupyter Notebook. I want to create one SQL table from this DataFrame. How can I do that?

Jun 26, 2020 in Python by akhtar
• 38,260 points
1,221 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the Sqlalchemy module to create a SQL table from a DataFrame. I have attached one example below for your reference.

from sqlalchemy import create_engine
import pandas as pd
data = pd.read_csv('marks.csv')
engine = create_engine('sqlite:///:memory:')
data.to_sql('data_table', engine)

I hope this will help you.

answered Jun 26, 2020 by MD
• 95,460 points

Related Questions In Python

0 votes
1 answer

How to create a train and test sample from one dataframe using pandas?

Hi, The below written code can help you ...READ MORE

answered Jul 4, 2019 in Python by Taj
• 1,080 points
5,756 views
0 votes
1 answer

How to create Pandas dataframe from Python list?

You can do it like this: import ...READ MORE

answered Apr 6, 2019 in Python by Likhita
1,322 views
0 votes
1 answer

How do I create a dataframe using a dictionary in pandas?

Hi @Hannah, You need to define your dictionary ...READ MORE

answered Nov 18, 2019 in Python by Eric
795 views
+2 votes
4 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,510 points
122,467 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
0 votes
1 answer

How to create a database engine using Sqlalchemy in Python?

Hi@akhtar, You can use the Sqlalchemy module in ...READ MORE

answered Jun 26, 2020 in Python by MD
• 95,460 points
1,593 views
0 votes
1 answer

error: while concatenation in a dataframe using pandas!

Hi@akhtar, When we use Concat function we have ...READ MORE

answered May 5, 2020 in Python by MD
• 95,460 points
3,776 views
0 votes
1 answer

How to delete column from pandas DataFrame?

Hi@akhtar, You can use the del command in ...READ MORE

answered Jun 24, 2020 in Python by MD
• 95,460 points
1,159 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP