Editing Database package

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 12: Line 12:
** [https://github.com/rmartinjak/mex-sqlite3 mex-sqlite3] – An extension for MATLAB® or GNU/octave to access sqlite3 databases
** [https://github.com/rmartinjak/mex-sqlite3 mex-sqlite3] – An extension for MATLAB® or GNU/octave to access sqlite3 databases
** [https://github.com/Andy1978/octave-sqlite octave-sqlite] - sqlite3 wrapper as an .oct file for GNU/Octave
** [https://github.com/Andy1978/octave-sqlite octave-sqlite] - sqlite3 wrapper as an .oct file for GNU/Octave
** [https://gnu-octave.github.io/octave-sqlite/ sqlite] - MATLAB® native sqlite compatible extension for GNU/octave.
* '''redis'''
* '''redis'''
** [https://gitlab.com/markuman/go-redis go-redis] - mex file extension for GNU/Octave to access Redis
** [https://gitlab.com/markuman/go-redis go-redis] - mex file extension for GNU/Octave to access Redis
Line 19: Line 18:


==Installation==
==Installation==
<small>This install guide covers the official (postgres) database package only.</small>
Requires octave struct. In ubuntu/debian based systems this is handled with
 
  apt install octave-struct
Requires octave struct, libpq-dev, and liboctave-dev. In ubuntu/debian based systems this is handled with
May also need
  apt install octave-struct libpq-dev liboctave-dev
apt install libpq-dev liboctave-dev
And if you want postgres
And if you want postgres
  apt install postgresql postgresql-client
  apt install postgresql postgresql-client
Line 42: Line 41:
  conn = pq_connect (setdbopts ("dbname", "mydatabase"));
  conn = pq_connect (setdbopts ("dbname", "mydatabase"));
Here, you are specifying a key-value pair. So you want to fill in a key (dbname), and that dbname is mydatabase.  
Here, you are specifying a key-value pair. So you want to fill in a key (dbname), and that dbname is mydatabase.  
Note: If you get an error similar to:
<pre>could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
</pre>
Try connecting via the IP/port instead of the unix socket. e.g.
conn = pq_connect (setdbopts ("dbname", "testdatabase", "host", "localhost", "port", "5433", "user", "pguser", "password", "pguserpassword"))
Now, you are ready to read the db:
Now, you are ready to read the db:
  N = pq_exec_params (conn, "select * from Table1;")
  N = pq_exec_params (conn, "select * from Table1;")
Line 100: Line 91:
===Cell2mat: Database Data Types Should be the Same===
===Cell2mat: Database Data Types Should be the Same===
Note that you must have all database columns be the same type in order for the values to not get potentially changed when using cell2mat. In the example above, if you have the UnixTime column above be a bigint, and the Value column be an Int, the UnixTime will get truncated. Changing the Value column to a bigint will resolve this.
Note that you must have all database columns be the same type in order for the values to not get potentially changed when using cell2mat. In the example above, if you have the UnixTime column above be a bigint, and the Value column be an Int, the UnixTime will get truncated. Changing the Value column to a bigint will resolve this.
===Built in Help Documentation===
octave:1> database_doc()


==Further Reading==
==Further Reading==
Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)