Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Saroj Dhiman
/
nlp_to_sql_query_generator
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5a9a893a
authored
Dec 12, 2023
by
Saroj Dhiman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload new file
1 parent
9bd31ff4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
conersion.py
conersion.py
0 → 100644
View file @
5a9a893
import
sqlite3
import
pandas
as
pd
import
csv
# creating a connection to the database
conn
=
sqlite3
.
connect
(
'database.sqlite3'
)
# creating a cursor object
cur
=
conn
.
cursor
()
# reading data from the CSV file
with
open
(
'cancer.csv'
)
as
f
:
reader
=
csv
.
reader
(
f
)
data
=
list
(
reader
)
# print(data)
# creating a table
# query = """
# CREATE TABLE Customer(
# CustomerID INT PRIMARY KEY,
# CustomerName VARCHAR(50),
# LastName VARCHAR(50),
# Country VARCHAR(50),
# Age int(2),
# Phone int(10)
# );
# """
# cur.execute(query)
cur
.
execute
(
"""CREATE TABLE CancerData ('index' INT,Year INT,nationality VARCHAR(30),
Gender VARCHAR(10),
cancer VARCHAR(10),
death INT,
age INT)"""
)
# # inserting data into the table
for
row
in
data
:
cur
.
execute
(
f
"INSERT INTO CancerData ('index', Year, nationality, Gender, cancer, death, age) values {tuple(row)}"
)
# committing changes
conn
.
commit
()
# closing the connection
conn
.
close
()
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment