Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 934515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:00:50+00:00 2026-05-15T21:00:50+00:00

I have a simple SQL question. I want to make a 3 column database

  • 0

I have a simple SQL question. I want to make a 3 column database and I have the following code:

sqlite3 meshdb.db "create table t1 (t1key INTEGER PRIMARY KEY, prideID, pubmedID);"

When I try to import a simple csv file with two columns (prideID and pubmedID), I get a “expected 3 columns of data but found 2” error. I want the t1key to be an integer, and automatically count up as new fields are added. Do I have to put NOT NULL in front of PRIMARY KEY to for this to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:00:52+00:00Added an answer on May 15, 2026 at 9:00 pm

    .import does not support reshaping the input (except from setting the separator). You need to import the CSV file into a temporary table and the insert that into the real table. Here is a example session:

    $ cat a.csv 
    1,2
    3,4
    5,6
    $ sqlite3 a.db
    SQLite version 3.6.23.1
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> create table foo(id integer primary key,x,y);
    sqlite> create temp table footmp(x,y);
    sqlite> .separator ,
    sqlite> .import a.csv footmp
    sqlite> select * from footmp;
    1,2
    3,4
    5,6
    sqlite> insert into foo(x,y) select * from footmp; 
    sqlite> select * from foo; 
    1,1,2
    2,3,4
    3,5,6
    sqlite> drop table footmp; 
    

    You see that ID is counted up. This is because a column with type INTEGER PRIMARY KEY is treated as an alias for the internal ROWID – which always is a unique, ascending number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create simple poll system. I have two question and two answers.
I have a seemly simple question with SQL that I am having trouble figuring
I have a simple SQL table which defines a set of hierarchical categories and
I want to have a database table that keeps data with revision history (like
I have a simple table in my SQL Server 2008 DB: Tasks_Table -id -task_complete
I'm new to postgreSQL and I have a simple question: I'm trying to create
I have the following setup for a simple application: generated LINQ to SQL classes
Some background: I have an database that I want to use linq-to-sql to update
I have a simple SQL query in PostgreSQL 8.3 that grabs a bunch of
I have a simple SQL query: Select ID, COUNT(ID) as Selections, OptionName, SUM(Units) as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.