author | František Kučera <franta-hg@frantovo.cz> |
Mon, 21 Feb 2022 00:43:11 +0100 | |
branch | v_0 |
changeset 329 | 5bc2bb8b7946 |
parent 324 | 3cbce8bb28c3 |
permissions | -rw-r--r-- |
297
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
<stránka |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
xmlns="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/strana" |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
<nadpis>Accessing SQLite, PostgreSQL and MySQL through ODBC</nadpis> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
<perex>use various DBMS for SQL transformations or data access</perex> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
<m:pořadí-příkladu>04200</m:pořadí-příkladu> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
<text xmlns="http://www.w3.org/1999/xhtml"> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
Since <m:a href="release-v0.16">v0.16</m:a> the <code>relpipe-tr-sql</code> module |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
uses the ODBC abstraction layer and thus we can access data in any DBMS (database management system). |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
Our program depends only on the generic API and the driver for particular DBMS is loaded dynamically depending on the configuration. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
<blockquote> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
ODBC (Open Database Connectivity) is an industry standard and provides API for accessing a DBMS. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
In late 80s several vendors (mostly from the Unix and database communities) established the SQL Access Group (SAG) |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
and then specified the Call Level Interface (CLI). ODBC, which is based on CLI, was published in early 90s. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
ODBC is available on many operating systems and there are at least two free software implementations: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
<a href="http://www.unixodbc.org/">unixODBC</a> and <a href="http://www.iodbc.org/">iODBC</a>. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
</blockquote> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
<p>For more information see the <m:a href="release-v0.16">v0.16 release notes</m:a>.</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
<h2>General concepts and configuration</h2> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
<strong>ODBC</strong>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
the API consisting of C functions; see the files <code>sql.h</code> and <code>sqlext.h</code> e.g. in unixODBC. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
<strong>Database driver</strong>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
a shared library (an <code>.so</code> file) |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
that implements the API and connects to particular DBMS (SQLite, PostgreSQL, MySQL, MariaDB, Firebird etc.); |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
is usually provided by the authors of given DBMS, sometimes writen by a third-party |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
<strong>Client</strong>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
a program that calls the API in order to access a database; our <code>relpipe-tr-sql</code> is a client |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
<strong>Data Source Name (DSN)</strong>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
the name of a preconfigured data source – when connecting, we need to know only the DSN – all parameters |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
(like server name, user name, password etc.) can be then looked-up in the configuration |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
<strong>Connection string</strong>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
a text string consisting of serialized parameters needed for connecting |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
– we can specify all parameters ad-hoc in the connection string without creating any permanent configuration; |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
a connection string can also refer to a DSN and add or override some parameters |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
There is some global configuration in the <code>/etc</code> directory. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
In <code>/etc/odbcinst.ini</code> we can a find list of ODBC drivers. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
Thanks to it, we can refer to a driver by its name (e.g. <code>SQLite3</code>) |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
instead of the path to the shared library (e.g. <code>/usr/lib/x86_64-linux-gnu/odbc/libsqlite3odbc.so</code>). |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
In <code>/etc/odbc.ini</code> we can find a list of global (for given computer) data sources. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
It is uncommon to put complete configurations in this file, because anyone would be able to read the passwords, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
but we can provide here just a <i>template</i> with public parameters like server name, port etc. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
and user will supply his own user name and password in the connection string or in his personal configuration file. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
The <code>~/.odbc.ini</code> contains personal configuration of given user. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
There are usually data sources including the passwords. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
Thus this file must be readable only by given user (<code>chmod 600 ~/.odbc.ini</code>). |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
Providing passwords in connection strings passed as CLI arguments is not a good practice due to security reasons: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
by default it is stored in the shell history and it is also visible to other users of the same machine in the list of running processes. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
The section name – in the <code>[]</code> brackets – is the DSN. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
Then there are parameters in form of <code>key=value</code> on each line. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
<h2>CLI options</h2> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
The <code>relpipe-tr-sql</code> and <code>relpipe-in-sql</code> support these relevant CLI options: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
<ul> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
<li> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
90 |
<code>--list-data-sources</code>: |
324
3cbce8bb28c3
relpipe-tr-sql and relpipe-in-sql --list-data-sources option has boolean parameter since v0.18
František Kučera <franta-hg@frantovo.cz>
parents:
300
diff
changeset
|
91 |
whether to |
297
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
lists available (configured) data sources in relational format (so we pipe the output to some output filter e.g. to <code>relpipe-out-tabular</code>) |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
</li> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
<li> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
95 |
<code>--data-source-name</code>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
96 |
specifies the DSN of a configured data source |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
97 |
</li> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
<li> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
99 |
<code>--data-source-string</code>: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
100 |
specifies the connections string for ad-hoc connection without need of any configuration |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
101 |
</li> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
102 |
</ul> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
103 |
|
324
3cbce8bb28c3
relpipe-tr-sql and relpipe-in-sql --list-data-sources option has boolean parameter since v0.18
František Kučera <franta-hg@frantovo.cz>
parents:
300
diff
changeset
|
104 |
<pre><![CDATA[$ relpipe-tr-sql --list-data-sources true | relpipe-out-tabular |
297
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
data_source: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
106 |
╭───────────────┬──────────────────────╮ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
107 |
│ name (string) │ description (string) │ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
108 |
├───────────────┼──────────────────────┤ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
109 |
│ sqlite-memory │ SQLite3 │ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
110 |
│ relpipe │ PostgreSQL Unicode │ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
111 |
╰───────────────┴──────────────────────╯ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
112 |
Record count: 2]]></pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
113 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
114 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
115 |
Because output of this command is relational, we can further process it in our relational pipelines. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
116 |
This output is also used for the Bash-completion for suggesting the DSN. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
117 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
118 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
119 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
120 |
If neither <code>--data-source-name</code> nor <code>--data-source-string</code> option is provided, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
121 |
a temporary in-memory SQLite database is used as default. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
122 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
123 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
124 |
<h2>SQLite</h2> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
125 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
126 |
<p>In Debian GNU/Linux and similar distributions we can install <a href="https://sqlite.org/">SQLite</a> ODBC driver by this command:</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
127 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
128 |
<pre>apt install libsqliteodbc</pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
129 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
130 |
<p>Which also installs the SQLite library that is all we need (because SQLite is a <i>serverless and self-contained</i> database).</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
131 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
132 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
133 |
Then we can use the default in-memory temporary database or specify the connection string ad-hoc, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
134 |
<m:a href="examples-in-sql-selecting-existing-database">access existing SQLite databases</m:a> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
135 |
or <m:a href="examples-in-filesystem-tr-sql-indexing">create new ones</m:a> – e.g. this command: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
136 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
137 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
138 |
<pre>… | relpipe-tr-sql --data-source-string 'Driver=SQLite3;Database=file:MyDatabase.sqlite'</pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
139 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
140 |
<p>will create the <code>MyDatabase.sqlite</code> file and fill it with relations that came from STDIN.</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
141 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
142 |
<p>For frequently used databases it is convenient to configure a data source in <code>~/.odbc.ini</code>:</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
143 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
144 |
<m:pre jazyk="ini"><![CDATA[[MyDatabase] |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
145 |
Driver=SQLite3 |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
146 |
Database=file:/home/hacker/MyDatabase.sqlite]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
147 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
148 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
149 |
and then connect to it simply using <code>--data-source-name MyDatabase</code> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
150 |
(both the option and the name will be suggested by Bash-completion). |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
151 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
152 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
153 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
154 |
The <a href="http://www.ch-werner.de/sqliteodbc/html/index.html">SQLite ODBC driver</a> supports several parameters that are described in its documentation. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
155 |
One of them is <code>LoadExt</code> that loads SQLite extensions: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
156 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
157 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
158 |
<m:pre jazyk="ini"><![CDATA[LoadExt=/home/hacker/libdemo.so]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
159 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
160 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
161 |
So we can write our own SQLite extension with custom functions or other features |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
162 |
(<a href="https://blog.frantovo.cz/c/383/Komplexita%20softwaru%3A%20%C5%98e%C5%A1en%C3%AD%20a%C2%A0prevence#toc_sqlite">example</a>) |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
163 |
or chose some existing one and load it into the SQLite connected through ODBC. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
164 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
165 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
166 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
167 |
<h2>PostgreSQL</h2> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
168 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
169 |
<p>In Debian GNU/Linux and similar distributions we can install <a href="https://www.postgresql.org/">PostgreSQL</a> ODBC driver by this command:</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
170 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
171 |
<pre>apt install odbc-postgresql</pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
172 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
173 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
174 |
PostgreSQL is very powerful DBMS (probably most advanced free software relational database system) |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
175 |
and utilizes the client-server architecture. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
176 |
This means that we also needs a server (can be also installed through <code>apt</code> like the driver). |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
177 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
178 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
179 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
180 |
Once we have a server – remote or local – we need to create a user (role). |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
181 |
For SQL transformations we configure a dedicated role that has no persistent schema and uses the temporary one as default, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
182 |
which means that all relations we create are lost at the end of the session (when the <code>relpipe-tr-sql</code> command finishes), |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
183 |
thus it behaves very similar to the SQLite in-memory database. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
184 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
185 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
186 |
<m:pre jazyk="sql"><![CDATA[CREATE USER relpipe WITH PASSWORD 'someSecretPassword'; |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
187 |
ALTER ROLE relpipe SET search_path TO 'pg_temp';]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
188 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
189 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
190 |
And then we <a href="https://odbc.postgresql.org/docs/config.html">configure</a> the ODBC data source: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
191 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
192 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
193 |
<m:pre jazyk="ini"><![CDATA[[postgresql-temp] |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
194 |
Driver=PostgreSQL Unicode |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
195 |
Database=postgres |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
196 |
Servername=localhost |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
197 |
Port=5432 |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
198 |
Username=relpipe |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
199 |
Password=someSecretPassword]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
200 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
201 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
202 |
Now we can use advanced PostgreSQL features for transforming data in our pipelines. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
203 |
We can also configure a DSN for another database that contains some useful data and other database objects, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
204 |
call existing business functions installed in such database, load data to or from this DB etc. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
205 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
206 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
207 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
208 |
<h2>MySQL</h2> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
209 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
210 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
211 |
If the <code>libmyodbc</code> package is missing in our distribution, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
212 |
the ODBC driver for <a href="https://dev.mysql.com/downloads/connector/odbc/">MySQL</a> can be downloaded from their website. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
213 |
We can get a binary package (<code>.deb</code>, <code>.rpm</code> etc.) or source code. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
214 |
If we are compiling from sources, we do something like this: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
215 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
216 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
217 |
<m:pre jazyk="bash"><![CDATA[cd mysql-connector-odbc-*-src/ |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
218 |
mkdir build |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
219 |
cd build |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
220 |
cmake ../ -DWITH_UNIXODBC=1 |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
221 |
make]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
222 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
223 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
224 |
We should use the driver in the same or similar version as the MySQL client library installed on our system. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
225 |
For example 8.x driver will not work with 5.x library. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
226 |
Successful compilation results in <code>libmyodbc*.so</code> files. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
227 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
228 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
229 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
230 |
Like PostgreSQL, also MySQL is a client-server, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
231 |
so we need a server where we create a database and some user account. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
232 |
As root through the <code>mysql mysql</code> command we execute: |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
233 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
234 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
235 |
<m:pre jazyk="sql"><![CDATA[CREATE DATABASE relpipe CHARACTER SET = utf8; |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
236 |
CREATE USER 'relpipe'@'localhost' IDENTIFIED BY 'someSecretPassword'; |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
237 |
GRANT ALL PRIVILEGES ON relpipe.* TO 'relpipe'@'localhost'; |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
238 |
FLUSH PRIVILEGES;]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
239 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
240 |
<p>As a normal user we add new data source to our <code>~/.odbc.ini</code> file:</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
241 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
242 |
<m:pre jazyk="ini"><![CDATA[[mysql-relpipe-localhost] |
300
b9bd0f06b4a1
MySQL seems to works well even with libmyodbc5a.so not only libmyodbc5w.so ODBC driver
František Kučera <franta-hg@frantovo.cz>
parents:
297
diff
changeset
|
243 |
Driver=/home/hacker/src/mysql/build/lib/libmyodbc5a.so |
297
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
244 |
Server=localhost |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
245 |
Port=3306 |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
246 |
Socket=/var/run/mysqld/mysqld.sock |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
247 |
User=relpipe |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
248 |
Password=someSecretPassword |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
249 |
Database=relpipe |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
250 |
InitStmt=SET SQL_MODE=ANSI_QUOTES; |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
251 |
Charset=utf8]]></m:pre> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
252 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
253 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
254 |
See that we have compiled the ODBC driver in our home directory |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
255 |
and even without installing it anywhere and registering it in the <code>/etc/odbcinst.ini</code> file, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
256 |
we can simply refer to the <code>.so</code> file from our <code>~/.odbc.ini</code>. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
257 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
258 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
259 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
260 |
If we set <code>Server=localhost</code>, the client-server communication does not go through TCP/IP |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
261 |
but rather through the unix domain socket specified in the <code>Socket</code> field. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
262 |
If we set <code>Server=127.0.0.1</code> or some remote IP address or domain name, the communication goes through TCP/IP on given port. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
263 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
264 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
265 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
266 |
The <code>SET SQL_MODE=ANSI_QUOTES;</code> init statement is important, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
267 |
because it tells MySQL server that it should support standard SQL "quoted" identifiers |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
268 |
instead of that `weird` MySQL style. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
269 |
We use the standard SQL while creating the tables. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
270 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
271 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
272 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
273 |
There are many other parameters, quite well |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
274 |
<a href="https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-configuration-connection-parameters.html">documented</a>. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
275 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
276 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
277 |
<p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
278 |
Now we can use MySQL as the <i>SQL engine</i> for transformations in our pipelines |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
279 |
and we can also access existing MySQL databases, |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
280 |
load data to and from them |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
281 |
or call functions and procedures installed on the server. |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
282 |
</p> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
283 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
284 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
285 |
</text> |
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
286 |
|
192b0059a6c4
Release v0.16 – ODBC in SQL + JACK MIDI
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
287 |
</stránka> |