Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
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

  • Android Java Project to Store,Read & Delete Data Using SharedPreferences Example
  • Android Java Project to Download Multiple Images From URL With Progressbar & Save it inside Gallery
  • Android Java Project to Capture Image From Camera & Save it inside Gallery
  • Android Java Project to Crop,Scale & Rotate Images Selected From Gallery and Save it inside SD Card
  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme