DATA Step, Macro, Functions and more

SQLite using Pipes

Reply
Occasional Contributor NDS
Occasional Contributor
Posts: 10

SQLite using Pipes

Hi,

I am trying to access a SQLite database using pipes as follows:

filename QUERY pipe 'sqlite3 home/data/MyDB.db3 "select field1 from table1"';
  options linesize = max;

    data mySet;
      infile QUERY delimiter = '|' missover dsd lrecl = 32767;
      input
         field1
      ;         
    run;

I have simplified the query, but the original runs fine from SQLite studio.

However when I run this, I get a single row in my data table with SQL ERROR in it.

If anyone can shed any light on this I'd appreciate it.

Many thanks

Nick

SAS Employee
Posts: 26

Re: SQLite using Pipes

Run your command in a bare DOS window instead of the IDE.

If it runs in the DOS window, we'll need to investiage PIPE further.

Occasional Contributor NDS
Occasional Contributor
Posts: 10

Re: SQLite using Pipes

Hi,

Sorry - took some time to get back to this. I have tried what you suggested and I have a couple of issues:

1. A simple SQL command runs fine from the prompt (i.e. Select * from MYTABLE) - and the same simple query runs fine from in SAS using pipes.

2. When I try to select from a view (from the prompt or SAS) I get an error that the column name can't be found (i.e. Select * from [myView]) this squery works fine in the IDE

It must be interpreting the query that defines the view correctly as it is looking for the right column.

Is there some issue selecting from views using sqlite3?

One possible issue is that the original .db3 file was created in a windows environment and I have copied it over to a unix environment. I tried dos2unix but that seemed to corrupt the file....

Any ideas?


Super User
Posts: 5,256

Re: SQLite using Pipes

Since it seems it's not SAS that is the issue, you might find answers in a different forum. The average SAS user have no experience with SQLite...;-)

Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 856 views
  • 0 likes
  • 3 in conversation