ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: database
Date: Fri, 25 Apr 2003 13:21:02 +0200	[thread overview]
Message-ID: <5.2.0.9.1.20030425131916.01527d38@server-1> (raw)
In-Reply-To: <20030425122352.587e40c5.taco@elvenkind.com>

[-- Attachment #1: Type: text/plain, Size: 1813 bytes --]

In addition to taco's stuff i attached what i could locate on my machine 
(last year i played a bit with mysql and storing xml and so)

Hans

>What you are asking for (MySQL I/O) cannot be done. The context
>command you refer to intended solely for syntax highlighting of
>SQL statements.
>
>However, you got me thinking. :)
>
>See attached context module and test file. It's extremely crude
>and more of a proof of concept than a full module, but it seems
>to work OK on the simple tests I threw at it. All of the commands
>and macros it provides are in the demonstration file.
>
>Stuff to keep in mind:
>
>- \write18 had better be enabled
>
>- the statement is fed to a 'mysql' in batchmode during \MySQLexecute
>
>- The result is saved to a file named \jobname-[Queryname]-result.dat
>
>- You always have to re-execute before you attempt to process the
>   the results
>
>- The 'Countexecutable' is supposed to return a single line that starts with
>   the number of lines of the \jobname-[Queryname]-result.dat file.
>
>- No error checking whatsoever is done. Spefically, nothing is done
>   about MySQL's output format, so you can expect problems with
>   embedded newlines and other specials characters
>
>The module is a joke, ok? But a fun one :-)
>
>Greetings, Taco
>
>
>On Wed, 23 Apr 2003 20:55:16 +0200, LEGUEDOIS, wrote:
>
> > but I don't know how to use this (how to use the result of the query, where
> > I write database connection's parameters...). Do you know where can I 
> find a
> > manual or any help?
>
>
>--
>groeten,
>
>Taco
>
>================================================================
>Deze e-mail is door E-mail VirusScanner van Planet Internet gecontroleerd 
>op virussen.
>Op http://www.planet.nl/evs staat een verwijzing naar de actuele lijst 
>waar op wordt gecontroleerd.
>

[-- Attachment #2: xmlvvsql.tex --]
[-- Type: text/plain, Size: 1139 bytes --]

% interface=en output=pdftex

\unprotect 

\def\??sq{@@sq}

\def\startSQLquery#1#2\stopSQLquery
  {\setvalue{\??sq:#1}{#2}}

\def\applySQLquery#1% last line is quit without ; 
  {\bgroup
\def\\{\rawcharacter{`\\}}%
   \long\def\next##1;##2%
     {\ifx##2\empty
        \immediate\write\scratchwrite{##1}%
        \@EA\gobbleuntil\@EA\relax
      \else
        \immediate\write\scratchwrite{##1;}%
        \@EA\next
      \fi##2}%
   \immediate\openout\scratchwrite=\bufferprefix\jobname-sql.sql
   \@EAEAEA\next\csname\??sq:#1\endcsname\empty\empty;\empty\relax
   \immediate\closeout\scratchwrite
   \executeSQLcommand
     {\bufferprefix\jobname-sql.sql}%
     {\bufferprefix\jobname-sql.log}%
   \egroup}

\def\executeSQLcommand#1#2%
%  {\executesystemcommand{c:/mysql/bin/mysql.exe < #1 > #2}}
  {\executesystemcommand{c:/mysql/bin/mysqldump.exe  -r #2 <
#1}}

\protect 

\starttext 

\startSQLquery{test}
  connect cod ;
%  select leerling into outfile "e:/tmp/test.tmp" from ws_p ;
%select data into outfile "e:/tmp/test.tmp" 
select data from ws_p ;
  quit
\stopSQLquery

\applySQLquery{test}

\typefile{e:/tmp/test.tmp}

\stoptext

[-- Attachment #3: Type: text/plain, Size: 597 bytes --]

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

  reply	other threads:[~2003-04-25 11:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-23 18:55 database LEGUEDOIS, Frederic
2003-04-25 10:23 ` database Taco Hoekwater
2003-04-25 11:21   ` Hans Hagen [this message]
2003-07-07 10:13 Database Willi Egger
2007-01-23  8:45 database Wolfgang Werners-Lucchini
2007-01-24  2:44 ` database Mojca Miklavec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5.2.0.9.1.20030425131916.01527d38@server-1 \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).