Re: [sqlite] .import FILE TABLE

2011-03-11 Thread jciliberti
Thank you, thank you, thank you. 



- Original Message - 
From: "Jim Morris"  
To: sqlite-users@sqlite.org 
Sent: Thursday, March 10, 2011 2:40:34 PM 
Subject: Re: [sqlite] .import FILE TABLE 

.separator "," 
.import myPath/myCSVfile myTable 

We use a "import" file with these commands. 


On 3/10/2011 2:32 PM, jcilibe...@comcast.net wrote: 
> Thanks, but doesn't seem to work: 
> 
> 
> I used command> 
> - Original Message - 
> From: "Gerry Snyder" 
> To: "General Discussion of SQLite Database" 
> Sent: Thursday, March 10, 2011 12:39:33 PM 
> Subject: Re: [sqlite] .import FILE TABLE 
> 
> On 3/10/2011 1:28 PM, jcilibe...@comcast.net wrote: 
>> Hello, thanks but adding separator "," doesn't seem to work. 
> 
> I tried the following commands: 
>> .import separator "," myPath/myCSVfile myTable 
>> . import separator , myPath/myCSVfile myTable 
>> . import myPath/myCSVfile myTable separator , 
>> . import myPath/myCSVfile myTable separator "," 
> 
> None worked: any ideas? Examination of the myCSVfile.txt shows [1, "Jack", 
> "Sammamish"] 
>> 
>> Unbelievably active user group! 
>> 
>> 
>> I have been unable to import a CSV text file from MS Access to sqlite: 
>> 1. Created a small table (3 fields and 1 record) in Access and exported it 
>> to a CSV text file named "myCSVfile.txt" 
>> 
>> 
>> 2. Transferred from PC to Mac. Opened file "myCSVfile.txt" ...looks OK eg: 
>> [1, "Jack", "Sammamish"] 
>> 
>> 
>> 3. Created a new DB ("myDB") and table ("myTable") in SQLite Database 
>> Browser eg: [ID:primaryKey Name:text City:text] 
>> 
>> 
>> 4. Opened the DB in terminal with> sqlite myPath/myDB 
> Does adding the line: 
> 
> .separator "," 
> 
> help? 
> 
>> 5. Entered command> .import myPath/myCSVfile myTable 
>> 
>> 
>> Always get back message: "line 1: expected 3 columns of data but found 1" 
>> 
>> 
>> Help! I've read many archived posts...so I know this should work. 
>> ___ 
>> sqlite-users mailing list 
>> sqlite-users@sqlite.org 
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 
>> 
> ___ 
> sqlite-users mailing list 
> sqlite-users@sqlite.org 
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 
> ___ 
> sqlite-users mailing list 
> sqlite-users@sqlite.org 
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 
> 
___ 
sqlite-users mailing list 
sqlite-users@sqlite.org 
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Fwd: database collision detection

2011-03-11 Thread Eugene N
Thank you all,
Learning is such a joy when people are helpful :)

Eugene

2011/3/11 Teg 

> Hello Eugene,
>
> How about initally attempting the fetch and if that fails, do the
> insert?  Since the results of a duplicate means you want the two
> additional blobs anyway.
>
> Select so and so
>
> on empty results
>
> Insert so and so.
>
> C
>
> Friday, March 11, 2011, 9:15:14 AM, you wrote:
>
> EN> Hello
>
> EN> I am just beginning my thorn-ridden way up the steep slope with SQLite
> and
> EN> C++ to keep me company. And i am stuck at one point, so if you could
> help me
> EN> to continue it would be awsome.
>
> EN> I have a database contaning a table with a layout like this:
>
> EN> NAME   PART1  PART2
> EN>  blobblob blob
> EN>  blobblob blob
> EN>   .........
>
> EN> I am thinking of creating it like:
>
> EN>  CREATE TABLE points (NAME blob unique, PART1 blob, PART2 blob);
>
>
> EN> Then, in a loop, i will obtain new blob tuples and insert them in my
> table:
>
>
> EN>  INSERT INTO points VALUES(?,?,?); // using prepare statement and
> bind
> EN> blob
>
>
> EN> Then comes a tricky bit:
>
>
> EN>   1) If there is a tuple with same NAME ( SQL error: column name is not
> EN> unique) already,
>
> EN>   2) I want to fetch its components PART1 and PART2
>
>
> EN> SELECT PART1, PART2 FROM points WHERE NAME = ?;
>
> EN>  // using prepare statement and bind blob
>
>
> EN> The problem is, i dont know how to *DETECT* a collision gracefully.
>
>
> EN> I first thought of looking at an error code, but i am not sure its a
> good
> EN> idea. Then
>
> EN> I heard somewhere about a thing called TRIGGERS, but still i am not
> sure, if
> EN> thats
>
> EN> the easiest way.
>
>
> EN> So, basically, how do you detect duplicates and handle them how you
> consider
> EN> appropriate?
>
>
> EN> Thanks,
>
>
> EN> Eugene
> EN> ___
> EN> sqlite-users mailing list
> EN> sqlite-users@sqlite.org
> EN> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
> --
> Best regards,
>  Tegmailto:t...@djii.com
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Fwd: database collision detection

2011-03-11 Thread Teg
Hello Eugene,

How about initally attempting the fetch and if that fails, do the
insert?  Since the results of a duplicate means you want the two
additional blobs anyway.

Select so and so

on empty results

Insert so and so.

C

Friday, March 11, 2011, 9:15:14 AM, you wrote:

EN> Hello

EN> I am just beginning my thorn-ridden way up the steep slope with SQLite and
EN> C++ to keep me company. And i am stuck at one point, so if you could help me
EN> to continue it would be awsome.

EN> I have a database contaning a table with a layout like this:

EN> NAME   PART1  PART2
EN>  blobblob blob
EN>  blobblob blob
EN>   .........

EN> I am thinking of creating it like:

EN>  CREATE TABLE points (NAME blob unique, PART1 blob, PART2 blob);


EN> Then, in a loop, i will obtain new blob tuples and insert them in my table:


EN>  INSERT INTO points VALUES(?,?,?); // using prepare statement and bind
EN> blob


EN> Then comes a tricky bit:


EN>   1) If there is a tuple with same NAME ( SQL error: column name is not
EN> unique) already,

EN>   2) I want to fetch its components PART1 and PART2


EN> SELECT PART1, PART2 FROM points WHERE NAME = ?;

EN>  // using prepare statement and bind blob


EN> The problem is, i dont know how to *DETECT* a collision gracefully.


EN> I first thought of looking at an error code, but i am not sure its a good
EN> idea. Then

EN> I heard somewhere about a thing called TRIGGERS, but still i am not sure, if
EN> thats

EN> the easiest way.


EN> So, basically, how do you detect duplicates and handle them how you consider
EN> appropriate?


EN> Thanks,


EN> Eugene
EN> ___
EN> sqlite-users mailing list
EN> sqlite-users@sqlite.org
EN> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



-- 
Best regards,
 Tegmailto:t...@djii.com

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] database collision detection

2011-03-11 Thread Simon Slavin

On 11 Mar 2011, at 2:26pm, Igor Tandetnik wrote:

> Eugene N  wrote:
>> The problem is, i dont know how to *DETECT* a collision gracefully.
> 
> You try to insert, and it fails with SQLITE_CONSTRAINT error.
> 
>> I first thought of looking at an error code, but i am not sure its a good
>> idea.
> 
> What are error codes for, in your opinion?

Rather than 'error codes', which implies something went wrong, let's call them 
'result codes' so they have less connotation of "you shouldn't have done that":



although further down the page it does switch to 'error codes', which should 
probably be cleared up sometime.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] database collision detection

2011-03-11 Thread Igor Tandetnik
Eugene N  wrote:
> The problem is, i dont know how to *DETECT* a collision gracefully.

You try to insert, and it fails with SQLITE_CONSTRAINT error.

> I first thought of looking at an error code, but i am not sure its a good
> idea.

What are error codes for, in your opinion?
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Fwd: database collision detection

2011-03-11 Thread Eugene N
Hello

I am just beginning my thorn-ridden way up the steep slope with SQLite and
C++ to keep me company. And i am stuck at one point, so if you could help me
to continue it would be awsome.

I have a database contaning a table with a layout like this:

NAME   PART1  PART2
 blobblob blob
 blobblob blob
  .........

I am thinking of creating it like:

 CREATE TABLE points (NAME blob unique, PART1 blob, PART2 blob);


Then, in a loop, i will obtain new blob tuples and insert them in my table:


 INSERT INTO points VALUES(?,?,?); // using prepare statement and bind
blob


Then comes a tricky bit:


  1) If there is a tuple with same NAME ( SQL error: column name is not
unique) already,

  2) I want to fetch its components PART1 and PART2


SELECT PART1, PART2 FROM points WHERE NAME = ?;

 // using prepare statement and bind blob


The problem is, i dont know how to *DETECT* a collision gracefully.


I first thought of looking at an error code, but i am not sure its a good
idea. Then

I heard somewhere about a thing called TRIGGERS, but still i am not sure, if
thats

the easiest way.


So, basically, how do you detect duplicates and handle them how you consider
appropriate?


Thanks,


Eugene
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Invitation to connect on LinkedIn

2011-03-11 Thread Nguyen Chinh via LinkedIn
LinkedIn
Nguyen Chinh requested to add you as a connection on LinkedIn:
--

Zarko,

I'd like to add you to my professional network on LinkedIn.

- Nguyen

Accept invitation from Nguyen Chinh
http://www.linkedin.com/e/-62mihx-gl4ugys7-2y/BuxMMT0h2nypvIvNsoWseeA2ULM8vQLhJFCC/blk/I20369524_60/pmpxnSRJrSdvj4R5fnhv9ClRsDgZp6lQs6lzoQ5AomZIpn8_c3pvd38RejoPc399bSd2i4N8mDFabP8NcP4RcjkUd38LrCBxbOYWrSlI/EML_comm_afe/

View invitation from Nguyen Chinh
http://www.linkedin.com/e/-62mihx-gl4ugys7-2y/BuxMMT0h2nypvIvNsoWseeA2ULM8vQLhJFCC/blk/I20369524_60/0MdBYQczkVdzcMcAALqnpPbOYWrSlI/svi/
 

--
DID YOU KNOW you can use your LinkedIn profile as your website? Select a vanity 
URL and then promote this address on your business cards, email signatures, 
website, etc
http://www.linkedin.com/e/-62mihx-gl4ugys7-2y/ewp/inv-21/


 
-- 
(c) 2011, LinkedIn Corporation
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users