LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-15-2017, 10:16 PM   #1
wBB
LQ Newbie
 
Registered: Jan 2017
Posts: 25

Rep: Reputation: Disabled
SQLite path configuration


I installed SQLite with "npm install sqlite3 --build-from-source = sqlite3" (on Linux Debian), which ran without problems. However, when trying to run SQLite via command line with "sqlite3", this command is not found: "-bash: sqlite3: command not found"
Already when running a script like this from the example below, everything worked OK.
===================

In a second option, I also uninstalled SQLite via npm and reinstalled as indicated below:

$tar xvfz sqlite-autoconf-3170000.tar.gz
$cd sqlite-autoconf-3170000
$./configure --prefix=/usr/local
$make
$make install

In this way the command "$ sqlite3" is recognized, however the script below stopped working and the following error message was shown:
Error: Cannot find module 'sqlite3'
===========================

Is there any path configuration missing from these two installation options?
The command "sqlite3" must be recognized in bash and the script also must be executed in bash. After all, sqlite is installed and running ...


SCRIPT TEST
Code:
#!/usr/bin/env node

var sqlite3 = require('sqlite3').verbose();  
var db = new sqlite3.Database('abcd');  
  
db.serialize(function() {
  db.run("create table if not exists user (id INT, dt TEXT)");
  
  var stmt = db.prepare("INSERT INTO user VALUES (?,?)");  
  for (var i = 0; i < 10; i++) {  
    
  var d = new Date();  
  var n = d.toLocaleTimeString();  
  stmt.run(i, n);  
  }  
  stmt.finalize();
  
  db.each("SELECT id, dt FROM user", function(err, row) {  
      console.log("User id : " + row.id, row.dt);  
  });  
});  
  
db.close();
 
Old 03-16-2017, 12:16 AM   #2
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Suppose there must be good reason for you not using the already packaged in Debian version? I would give the packaged version a try more than likely will have a better outcome using it.

Code:
~$ apt-cache policy sqlite3
sqlite3:
  Installed: (none)
  Candidate: 3.8.7.1-1+deb8u2
  Version table:
     3.8.7.1-1+deb8u2 0
        500 http://ftp.de.debian.org/debian/ jessie/main amd64 Packages
     3.8.7.1-1+deb8u1 0
        500 http://security.debian.org/ jessie/updates/main amd64 Packages
 
Old 03-16-2017, 09:57 AM   #3
wBB
LQ Newbie
 
Registered: Jan 2017
Posts: 25

Original Poster
Rep: Reputation: Disabled
Yes, there is a good reason: SQLite isn't intalled in this Debian version.
I'm using an embedded device called Beaglebone Black, which runs on Linux Debian prepared for it. There is a Linux Debian Jessie 8.6 image on its webpage. It's the first link to linux image as shown below:

Jessie for BeagleBone via microSD card
Debian 8.6 2016-11-06 4GB SD LXQT image for BeagleBone

https://debian.beagleboard.org/images/bone-debian-8.6-lxqt-4gb-armhf-2016-11-06-4gb.img.xz

So, for this reason I'm trying to install (unsuccessfully) SQLite and I'm getting some unreported errors.
Please, could you help me solve the problem? I'm a newbie Linux user, SQLite user, and newbie for "many other things more" user.
 
Old 03-16-2017, 11:35 AM   #4
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by wBB View Post
Yes, there is a good reason: SQLite isn't intalled in this Debian version.
I'm using an embedded device called Beaglebone Black, which runs on Linux Debian prepared for it. There is a Linux Debian Jessie 8.6 image on its webpage. It's the first link to linux image as shown below:

Jessie for BeagleBone via microSD card
Debian 8.6 2016-11-06 4GB SD LXQT image for BeagleBone

https://debian.beagleboard.org/images/bone-debian-8.6-lxqt-4gb-armhf-2016-11-06-4gb.img.xz

So, for this reason I'm trying to install (unsuccessfully) SQLite and I'm getting some unreported errors.
Please, could you help me solve the problem? I'm a newbie Linux user, SQLite user, and newbie for "many other things more" user.
Lovely one of them distributions that are not complete well hopefully this will work. First you need to install the build-essential package and apt-src if it is not installed at the same time. Then mkdir src and cd src to change into the directory that you just created for holding the source it downloads now on this page below it tells you the rest of the steps. For the source line in your /etc/apt/sources.list you want.

Code:
deb-src http://ftp.de.debian.org/debian/ jessie main non-free contrib
Where it tells you to modify dpkg-buildpackage debian/rules options leave them alone with the defaults they install with and follow the rest of the instructions.

https://wiki.debian.org/apt-src

Edit: To install the packages mentioned apt-get install build-essential apt-src.

Last edited by HappyTux; 03-16-2017 at 11:40 AM.
 
Old 03-16-2017, 12:16 PM   #5
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Quote:
Originally Posted by wBB
I also uninstalled SQLite via npm
Try reinstalling via npm because you need both the system sqlite3 package, to run from the command line, and the node.js sqlite3 module, to run your script.

If you can use a package manager:
https://packages.debian.org/jessie/sqlite3
https://packages.debian.org/jessie/node-sqlite3
 
Old 03-16-2017, 02:44 PM   #6
wBB
LQ Newbie
 
Registered: Jan 2017
Posts: 25

Original Poster
Rep: Reputation: Disabled
HappyTux,
I don't know if I did everything right (I hope so...), but it did not work. The same problem remains. Thank you for your attention. If you have any other suggestions, I'd appreciate it.

norobro
I had imagined installing the two packages to try to solve the problem, but that is an idea that doesn't seem right. I don't know, but it seems wrong to me to have two different packages to do the same thing. As I said before, I'm newbie and my experience is not relevant...

I'll try to find some other alternative, but if I can't, I'll follow your suggestion. Anyway thank you for your attention and time.
 
Old 03-16-2017, 08:27 PM   #7
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by wBB View Post
HappyTux,
I don't know if I did everything right (I hope so...), but it did not work. The same problem remains. Thank you for your attention. If you have any other suggestions, I'd appreciate it.

norobro
I had imagined installing the two packages to try to solve the problem, but that is an idea that doesn't seem right. I don't know, but it seems wrong to me to have two different packages to do the same thing. As I said before, I'm newbie and my experience is not relevant...

I'll try to find some other alternative, but if I can't, I'll follow your suggestion. Anyway thank you for your attention and time.
Hmm probably need the two other packages already mentioned installed as well. Now you may have to build them from source too but before that what is in the sources.list you have on the machine right now.
 
Old 03-17-2017, 10:08 AM   #8
wBB
LQ Newbie
 
Registered: Jan 2017
Posts: 25

Original Poster
Rep: Reputation: Disabled
I uninstalled the previous packages and I reinstalled as indicated by norobro. Now there are both packages and both work. One package to run scripts and another for executing the sqlite in command-line bash. As I said before, I don't like this idea, but I have no choice for now.

My source.list file is the same as the one originally installed:
Code:
deb http://httpredir.debian.org/debian/ jessie main contrib non-free
# deb-src http://httpredir.debian.org/debian/ jessie main contrib non-free

deb http://httpredir.debian.org/debian/ jessie-updates main contrib non-free
# deb-src http://httpredir.debian.org/debian/ jessie-updates main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
# deb-src http://security.debian.org/ jessie/updates main contrib non-free

# deb http://httpredir.debian.org/debian jessie-backports main contrib non-free
##deb-src http://httpredir.debian.org/debian jessie-backports main contrib non-free

deb https://deb.nodesource.com/node_0.12 jessie main
# deb-src https://deb.nodesource.com/node_0.12 jessie main


#Kernel source (repos.rcn-ee.com) : https://github.com/RobertCNelson/linux-stable-rcn-ee
#
#git clone https://github.com/RobertCNelson/linux-stable-rcn-ee
#cd ./linux-stable-rcn-ee
#git checkout `uname -r` -b tmp
#
deb [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main
# deb-src [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main
 
Old 03-17-2017, 03:31 PM   #9
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by wBB View Post
I uninstalled the previous packages and I reinstalled as indicated by norobro. Now there are both packages and both work. One package to run scripts and another for executing the sqlite in command-line bash. As I said before, I don't like this idea, but I have no choice for now.

My source.list file is the same as the one originally installed:
Code:
deb http://httpredir.debian.org/debian/ jessie main contrib non-free
# deb-src http://httpredir.debian.org/debian/ jessie main contrib non-free

deb http://httpredir.debian.org/debian/ jessie-updates main contrib non-free
# deb-src http://httpredir.debian.org/debian/ jessie-updates main contrib non-free

deb http://security.debian.org/ jessie/updates main contrib non-free
# deb-src http://security.debian.org/ jessie/updates main contrib non-free

# deb http://httpredir.debian.org/debian jessie-backports main contrib non-free
##deb-src http://httpredir.debian.org/debian jessie-backports main contrib non-free

deb https://deb.nodesource.com/node_0.12 jessie main
# deb-src https://deb.nodesource.com/node_0.12 jessie main


#Kernel source (repos.rcn-ee.com) : https://github.com/RobertCNelson/linux-stable-rcn-ee
#
#git clone https://github.com/RobertCNelson/linux-stable-rcn-ee
#cd ./linux-stable-rcn-ee
#git checkout `uname -r` -b tmp
#
deb [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main
# deb-src [arch=armhf] http://repos.rcn-ee.com/debian/ jessie main

Well with that sources.list you should never have to have built from source at all it should have been available according to packages.debian.org it is built for armhf.

https://packages.debian.org/search?s...ywords=sqlite3

To check which version of the sqlite3 you are running use in bash which sqlite3 and put a line in the script echo "which sqlite3". If they are both the same then you can delete the package or source install depending on which is used.
 
Old 03-17-2017, 07:59 PM   #10
wBB
LQ Newbie
 
Registered: Jan 2017
Posts: 25

Original Poster
Rep: Reputation: Disabled
On Bash:
SQLite version 3.17.0 2017-02-13 16:02:40

On script "echo" raises a error:
echo "which sqlite"

I believe both are the same version, but I didn't get to check from script.
 
Old 03-17-2017, 09:44 PM   #11
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by wBB View Post
On Bash:
SQLite version 3.17.0 2017-02-13 16:02:40

On script "echo" raises a error:
echo "which sqlite"

I believe both are the same version, but I didn't get to check from script.
That is not the output of a which sqlite3 it returns the path to the binary it finds, that is a --version output.

Code:
:~$ which bash
/bin/bash

:~$ bash --version
bash --version
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
And now I look back at that script it is not a bash script like you said but rather a node script so it probably will not execute that echo bash command not sure though never ran one before. As well that could be the reason for the failure to find the sqlite3 originally if that script does not set a proper path it will not find the binary it is looking for.
 
Old 03-18-2017, 09:25 AM   #12
wBB
LQ Newbie
 
Registered: Jan 2017
Posts: 25

Original Poster
Rep: Reputation: Disabled
You really are a very patient guy... You're right! I forgot that I was working on a Node script and not on bash script . Now I did a bash script and I got the same result in command line and bash script, like you said:
/usr/local/bin/sqlite3

For now, I think that I should work with two sqlite3 instances: one for bash and one for nodejs, as before. I am satisfied though still disagreeing with this option.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Sqlite-Commander - A ncurses based tool to display the records and tables of a sqlite database LXer Syndicated Linux News 0 01-02-2011 08:11 AM
mutt return-path configuration jayasekar Linux - Software 0 05-11-2010 01:47 AM
Redhat kernel configuration file - path torrent55 Linux - Newbie 2 10-27-2008 12:28 PM
Redhat kernel configuration file - path torrent55 Red Hat 3 10-27-2008 01:43 AM
changing the path of GNOME configuration files ges Red Hat 0 06-17-2005 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration