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 in Python by akhtar
• 33,120 points
75 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 by MD
• 78,020 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 3, 2019 in Python by Taj
• 1,080 points
3,618 views
0 votes
1 answer

How to create Pandas dataframe from Python list?

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

answered Apr 5, 2019 in Python by Likhita
446 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
136 views
+2 votes
2 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
27,160 views
+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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,560 views
0 votes
0 answers
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 in Python by MD
• 78,020 points
159 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 in Python by MD
• 78,020 points
395 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 in Python by MD
• 78,020 points
107 views