Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Sitemap
Menu

Python 3 Script to Import CSV File Data inside SQLite Table & Database in Command Line

Posted on February 15, 2023

 

 

Welcome folks today in this blog post we will be importing csv file data inside sqlite table and database in command line. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

 

pip install csv_to_sqlite

 

 

And after that you need to make an app.py file and copy paste the following code

 

 

app.py

 

 

Python
1
2
3
4
5
6
import csv_to_sqlite
 
# all the usual options are supported
options = csv_to_sqlite.CsvOptions(typing_style="full", encoding="windows-1250")
input_files = ["data.csv"] # pass in a list of CSV files
csv_to_sqlite.write_csv(input_files, "output.sqlite", options)

 

 

And now we need to make the data.csv file and copy paste the following code

 

 

data.csv

 

 

1
2
3
4
5
name,age,country
john,24,india
kim,45,new zealand
austin,67,USA
trent,78,UK

 

 

python app.py

 

 

 

 

 

And now if you view the output.db inside the sql database viewer as shown below

 

 

 

Recent Posts

  • Build a Fixed Deposit Interest Calculator Using Amount and Time in Browser Using HTML5 & Javascript
  • How to Download Files From URL in Node.js Using Node-Downloader-Helper Library
  • Angular 10 Image Carousel and Video Gallery Lightbox Modal Slider Using ng-image-slider Library
  • React Unsplash Api Photo Search App
  • React Form Validation Using Formik and Yup
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • javascript
  • Koajs
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme