SQLite CSV import

I am using SQLite build-in import command for importing records from text files.

The code being follows:

$ sqlite3 dbname.db
SQLite version 3.1.3
Enter ".help" for instructions
sqlite> .separator "\t"

Once I have set the field separator, I do import:

sqlite> .import filename.txt tablename

This solves my purpose but have any one tried on any user-defined function to import data to sqlite.

 #

I want to update ASCII file with fixed length field (means first 8 char empo, next 20 char is emp name and then next line. this recornds is avalable in one flat file. i want to upload this in splite database. then i want to upload this data into oracle. Is this is possible.

 
 #

I have come across a CSV reading module in Tcllib, u can give it a try, it will take care of the quotes and other nastiness.

 
 #

You can use tksqlite application available for download at:

http://reddog.s35.xrea.com/wiki/TkSQLite.html

It is the best free tool for working with sqlite.

 
 #

For sqlite I use the mode command, the codes is like this:

sqlite> .mode csv
sqlite> .import ./filename.csv tablename

The mode command automatically choose the default separator.

 
 #

I hope you are going in right way, but instead you can fire a
system call to execute the same command:

$ sqlite3 -separator , dbname.db ".import filename.csv tablename"

this one line is enough then any user-defined function.

 

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

SEO Architect,SEO Specialist reflect my values.

By enduring black hat methods the SEO industry is setting itself up for washout and sleepwalking into oblivion.

Jobs in India