relpipe-data/examples-in-sql-selecting-existing-database.xml
branchv_0
changeset 297 192b0059a6c4
parent 279 de1b49ba06f1
equal deleted inserted replaced
296:418e11eb6fea 297:192b0059a6c4
     8 
     8 
     9 	<text xmlns="http://www.w3.org/1999/xhtml">
     9 	<text xmlns="http://www.w3.org/1999/xhtml">
    10 		
    10 		
    11 		<p>
    11 		<p>
    12 			Both the <code>relpipe-tr-sql</code> and <code>relpipe-in-sql</code>
    12 			Both the <code>relpipe-tr-sql</code> and <code>relpipe-in-sql</code>
    13 			support the option <code>--file</code> and can store data in a file instead of just in-memory.
    13 			support options <code>--data-source-name</code> and <code>--data-source-string</code>
    14 			Primary purpose of this option is to offload to HDD and be able to process more data whithout consuming too much RAM.
    14 			that can be used for connecting to a different database than the in-memory SQLite one.
    15 			So such file is usually a temporary one and is deleted immediately after the transformation.
    15 			This is useful if we want to offload to HDD and be able to process more data whithout consuming too much RAM.
    16 			But we can also direct it to an existing file and append new relations to it.
    16 			Or if we want to access an existing database instead of just transforming records from the STDIN to STDOUT.
    17 			Or we can create a new file and do not delete it – using the <code>--file-keep true</code> option.
    17 			These options allow connecting to any DBMS.
    18 		</p>
    18 		</p>
    19 		
    19 		
    20 		<p>
    20 		<p>
    21 			Thus we can use the <code>relpipe-in-sql</code> as a database client to access existing SQLite files and SELECT from them (and then convert the results to any supported format).
    21 			Thus we can use the <code>relpipe-in-sql</code> as a database client to access existing SQLite files and SELECT from them (and then convert the results to any supported format).
    22 			An we can use the <code>relpipe-tr-sql</code> as an output filter which converts relational data to a SQLite file that can be queried later.
    22 			And we can use the <code>relpipe-tr-sql</code> as an output filter which converts relational data to a SQLite file that can be queried later.
    23 		</p>
    23 		</p>
    24 		
    24 		
    25 		<p>
    25 		<p>
    26 			SQLite is a popular format used by many applications to store structured data.
    26 			SQLite is a popular format used by many applications to store structured data.
    27 			Version control systems (VCS) like <a href="https://www.monotone.ca/">Monotone</a> or <a href="https://fossil-scm.org/">Fossil</a>
    27 			Version control systems (VCS) like <a href="https://www.monotone.ca/">Monotone</a> or <a href="https://fossil-scm.org/">Fossil</a>
    33 		</p>
    33 		</p>
    34 		
    34 		
    35 		<m:pre jazyk="bash"><![CDATA[fossil clone http://www.sqlite.org/cgi/src sqlite.fossil]]></m:pre>
    35 		<m:pre jazyk="bash"><![CDATA[fossil clone http://www.sqlite.org/cgi/src sqlite.fossil]]></m:pre>
    36 		
    36 		
    37 		<p>
    37 		<p>
    38 			We can then query it using <m:name/> tools:
    38 			We can then query the database file <code>sqlite.fossil</code> using <m:name/> tools:
    39 		</p>
    39 		</p>
    40 		
    40 		
    41 		<m:pre jazyk="bash"><![CDATA[relpipe-in-sql \
    41 		<m:pre jazyk="bash"><![CDATA[relpipe-in-sql \
    42 	--file sqlite.fossil \
    42 	--data-source-string 'Driver=SQLite3;Database=file:sqlite.fossil' \
    43 	--relation tickets "
    43 	--relation tickets "
    44 		SELECT 
    44 		SELECT 
    45 			type,
    45 			type,
    46 			status,
    46 			status,
    47 			count(*) AS count
    47 			count(*) AS count