ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* LuaTeX/ConTeXt connect to SQL Server
@ 2014-05-26 16:38 Matt Baker
  2014-05-26 19:05 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Baker @ 2014-05-26 16:38 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 2065 bytes --]

FROM MY POSTING AT:
http://tex.stackexchange.com/questions/180018/luatex-context-connect-to-sql-server?noredirect=1#comment415824_180018

I am looking to connect ConTeXt to a SQL Server database. I have looked
through the manuals, and even read pragma-ade's SQL PDF (which, for me,
seems a bit abstract). I am not extremely familiar with Lua but have read
up on the language (I am more familiar with JS). For LaTex I used nlatexdb
which did the trick, but LaTex isn't able to do what ConTeXt can.

   -

   The connection needs to use Windows Authentication.
   -

   The document is set up as a letter with an environment that it pulls
   from.
   -

   It would be preferable to have the connection and queries be seperate
   from the letter itself, and be able to place variables into the letter that
   can be populated through the queries (much like nlatexdb) if possible.
   - example: Dear ??first ??last, Thank you for your interest in
      ??product... etc.

I am rather new to ConText and just starting to get the hang of it, long
time latex user, the transition starts off rather confusing, but once it
makes sense it opens up a whole toolbox of available tools which is great.
Just need this one last tool.

Any help would be much appreciated.

EDIT:: Honestly I haven't gotten to any point that I felt I could attempt
trying the connection. Looking at the SQL PDF from pragma-ade it should
look something like:

    local presets = {
    server = "XXX\XXX",
    Database = "Customer",
    Integrated Security = "True",
    }
    presets.id = "XXX"
    local template = [[
    SELECT
    'Control_Content'
    FROM
    'Customer.dbo.Report_Client_Data'
    WHERE
    'Control_Name' LIKE 'Long_Name' AND 'Client_Id' = 154;
     ]]

    local data, keys = utilities.sql.execute {
    presets = presets,
    template = template,
    variables = {},
    }

I can't seem to find where or how the connection is being made, except
perhaps where utilities.sql.execute is called, but I can't find any
information anywhere about such a call in lua or context...

[-- Attachment #1.2: Type: text/html, Size: 9031 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: LuaTeX/ConTeXt connect to SQL Server
  2014-05-26 16:38 LuaTeX/ConTeXt connect to SQL Server Matt Baker
@ 2014-05-26 19:05 ` Hans Hagen
  2014-05-26 19:48   ` Matt Baker
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2014-05-26 19:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 5/26/2014 6:38 PM, Matt Baker wrote:
> FROM MY POSTING AT:
> http://tex.stackexchange.com/questions/180018/luatex-context-connect-to-sql-server?noredirect=1#comment415824_180018
>
> I am looking to connect ConTeXt to a SQL Server database. I have looked
> through the manuals, and even read pragma-ade's SQL PDF (which, for me,
> seems a bit abstract). I am not extremely familiar with Lua but have read
> up on the language (I am more familiar with JS). For LaTex I used nlatexdb
> which did the trick, but LaTex isn't able to do what ConTeXt can.
>
>     -
>
>     The connection needs to use Windows Authentication.
>     -
>
>     The document is set up as a letter with an environment that it pulls
>     from.
>     -
>
>     It would be preferable to have the connection and queries be seperate
>     from the letter itself, and be able to place variables into the letter that
>     can be populated through the queries (much like nlatexdb) if possible.
>     - example: Dear ??first ??last, Thank you for your interest in
>        ??product... etc.
>
> I am rather new to ConText and just starting to get the hang of it, long
> time latex user, the transition starts off rather confusing, but once it
> makes sense it opens up a whole toolbox of available tools which is great.
> Just need this one last tool.
>
> Any help would be much appreciated.
>
> EDIT:: Honestly I haven't gotten to any point that I felt I could attempt
> trying the connection. Looking at the SQL PDF from pragma-ade it should
> look something like:
>
>      local presets = {
>      server = "XXX\XXX",
>      Database = "Customer",
>      Integrated Security = "True",
>      }

I have no clue where get that setup from as the manual says:

local presets = {
     database = "test",
     username = "root",
     password = "none",
     host     = "localhost",
     port     = 3306,
}

or something like that. The same kind of connection info that the mysql 
client needs.

>      presets.id = "XXX"

?

>      local template = [[
>      SELECT
>      'Control_Content'
>      FROM
>      'Customer.dbo.Report_Client_Data'
>      WHERE
>      'Control_Name' LIKE 'Long_Name' AND 'Client_Id' = 154;
>       ]]
>
>      local data, keys = utilities.sql.execute {
>      presets = presets,
>      template = template,
>      variables = {},
>      }

should work given a proper preset table

> I can't seem to find where or how the connection is being made, except
> perhaps where utilities.sql.execute is called, but I can't find any
> information anywhere about such a call in lua or context...

you can best start with using the command line client approach:

   sql.setmethod("client")

because the other methods assume a library that matches your luatex 
(this should works ok with regular mysql or swiglib bindings but it adds 
a level of complication)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: LuaTeX/ConTeXt connect to SQL Server
  2014-05-26 19:05 ` Hans Hagen
@ 2014-05-26 19:48   ` Matt Baker
  2014-05-26 20:56     ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Baker @ 2014-05-26 19:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 5067 bytes --]

I apologize, I'm not completely understanding you.  So the reason I have:
 local presets = {
     server = "XXX\XXX",
     Database = "Customer",
     Integrated Security = "True",
     }
Is it would need to look something like this - or an equivalent.  There
Server would need to be the location of the DB Server, then the DB name,
and then some way to tell it to utilize windows authentication (this model
is based lightly on the C# connection model).

Is there not a prebuilt library to access SQL built into the LuaTeX/ConTeXT
libraries?  It seems that there should be a method in which I could include
a set of database queries in an external document that can link to the tex
document.  The closest I am to being familiar with any of this is Nlatexdb
(based off of latexdb and rlatexdb) http://www.ctan.org/pkg/nlatexdb .
I am rather new to ConTeXT and Lua so I am struggling with wrapping my head
around all of this as it is.
Perhaps if you could show me an example document that links to a DB might
be beneficial... I was hoping you would have shown this at the end of your
PDF.

Thanks!


On Mon, May 26, 2014 at 1:05 PM, Hans Hagen <pragma@wxs.nl> wrote:

> On 5/26/2014 6:38 PM, Matt Baker wrote:
>
>> FROM MY POSTING AT:
>> http://tex.stackexchange.com/questions/180018/luatex-
>> context-connect-to-sql-server?noredirect=1#comment415824_180018
>>
>> I am looking to connect ConTeXt to a SQL Server database. I have looked
>> through the manuals, and even read pragma-ade's SQL PDF (which, for me,
>> seems a bit abstract). I am not extremely familiar with Lua but have read
>> up on the language (I am more familiar with JS). For LaTex I used nlatexdb
>> which did the trick, but LaTex isn't able to do what ConTeXt can.
>>
>>     -
>>
>>     The connection needs to use Windows Authentication.
>>     -
>>
>>     The document is set up as a letter with an environment that it pulls
>>     from.
>>     -
>>
>>     It would be preferable to have the connection and queries be seperate
>>     from the letter itself, and be able to place variables into the
>> letter that
>>     can be populated through the queries (much like nlatexdb) if possible.
>>     - example: Dear ??first ??last, Thank you for your interest in
>>
>>        ??product... etc.
>>
>> I am rather new to ConText and just starting to get the hang of it, long
>> time latex user, the transition starts off rather confusing, but once it
>> makes sense it opens up a whole toolbox of available tools which is great.
>> Just need this one last tool.
>>
>> Any help would be much appreciated.
>>
>> EDIT:: Honestly I haven't gotten to any point that I felt I could attempt
>> trying the connection. Looking at the SQL PDF from pragma-ade it should
>> look something like:
>>
>>      local presets = {
>>      server = "XXX\XXX",
>>      Database = "Customer",
>>      Integrated Security = "True",
>>      }
>>
>
> I have no clue where get that setup from as the manual says:
>
> local presets = {
>     database = "test",
>     username = "root",
>     password = "none",
>     host     = "localhost",
>     port     = 3306,
> }
>
> or something like that. The same kind of connection info that the mysql
> client needs.
>
>       presets.id = "XXX"
>>
>
> ?
>
>
>       local template = [[
>>      SELECT
>>      'Control_Content'
>>      FROM
>>      'Customer.dbo.Report_Client_Data'
>>      WHERE
>>      'Control_Name' LIKE 'Long_Name' AND 'Client_Id' = 154;
>>       ]]
>>
>>      local data, keys = utilities.sql.execute {
>>      presets = presets,
>>      template = template,
>>      variables = {},
>>      }
>>
>
> should work given a proper preset table
>
>
>  I can't seem to find where or how the connection is being made, except
>> perhaps where utilities.sql.execute is called, but I can't find any
>> information anywhere about such a call in lua or context...
>>
>
> you can best start with using the command line client approach:
>
>   sql.setmethod("client")
>
> because the other methods assume a library that matches your luatex (this
> should works ok with regular mysql or swiglib bindings but it adds a level
> of complication)
>
> Hans
>
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
> ____________________________________________________________
> _______________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/
> listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ____________________________________________________________
> _______________________
>

[-- Attachment #1.2: Type: text/html, Size: 8380 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: LuaTeX/ConTeXt connect to SQL Server
  2014-05-26 19:48   ` Matt Baker
@ 2014-05-26 20:56     ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2014-05-26 20:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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

On 5/26/2014 9:48 PM, Matt Baker wrote:
> I apologize, I'm not completely understanding you.  So the reason I have:
>   local presets = {
>       server = "XXX\XXX",
>       Database = "Customer",
>       Integrated Security = "True",
>       }
> Is it would need to look something like this - or an equivalent.  There
> Server would need to be the location of the DB Server, then the DB name,
> and then some way to tell it to utilize windows authentication (this model
> is based lightly on the C# connection model).

no, it should look like this:

local presets = {
     database = "test",
     username = "root",
     password = "none",
     host     = "localhost",
     port     = 3306,
}

You should use lowercase keys. Spaces in keys are impossible anyway 
unless you use ["foo bar"] = "xxx". It's Lua, so some basic 
understanding of Lua helps.

I'm unaware of windows auth, but username/pwd should work okay.

> Is there not a prebuilt library to access SQL built into the LuaTeX/ConTeXT
> libraries?  It seems that there should be a method in which I could include
> a set of database queries in an external document that can link to the tex

\usemodule[sql]

> document.  The closest I am to being familiar with any of this is Nlatexdb
> (based off of latexdb and rlatexdb) http://www.ctan.org/pkg/nlatexdb .
> I am rather new to ConTeXT and Lua so I am struggling with wrapping my head
> around all of this as it is.

The interface in context is an abstraction layer that can use several 
methods.

- the command line mysql program (client)
- the luasql library (not the best piece of code)
- the swiglib lua binding

and starting with the client method is easiest as one can also mimmick 
that on the command line.

> Perhaps if you could show me an example document that links to a DB might
> be beneficial... I was hoping you would have shown this at the end of your
> PDF.

attached some left-overs from the 2012 context conference

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------

[-- Attachment #2: demo-sql.pdf --]
[-- Type: application/x-pdf, Size: 31244 bytes --]

[-- Attachment #3: demo-sql.tex --]
[-- Type: application/x-tex, Size: 5458 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* LuaTeX/ConTeXt connect to SQL Server
@ 2014-05-23 19:47 Matt Baker
  0 siblings, 0 replies; 5+ messages in thread
From: Matt Baker @ 2014-05-23 19:47 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 2065 bytes --]

FROM MY POSTING AT:
http://tex.stackexchange.com/questions/180018/luatex-context-connect-to-sql-server?noredirect=1#comment415824_180018

I am looking to connect ConTeXt to a SQL Server database. I have looked
through the manuals, and even read pragma-ade's SQL PDF (which, for me,
seems a bit abstract). I am not extremely familiar with Lua but have read
up on the language (I am more familiar with JS). For LaTex I used nlatexdb
which did the trick, but LaTex isn't able to do what ConTeXt can.

   -

   The connection needs to use Windows Authentication.
   -

   The document is set up as a letter with an environment that it pulls
   from.
   -

   It would be preferable to have the connection and queries be seperate
   from the letter itself, and be able to place variables into the letter that
   can be populated through the queries (much like nlatexdb) if possible.
   - example: Dear ??first ??last, Thank you for your interest in
      ??product... etc.

I am rather new to ConText and just starting to get the hang of it, long
time latex user, the transition starts off rather confusing, but once it
makes sense it opens up a whole toolbox of available tools which is great.
Just need this one last tool.

Any help would be much appreciated.

EDIT:: Honestly I haven't gotten to any point that I felt I could attempt
trying the connection. Looking at the SQL PDF from pragma-ade it should
look something like:

    local presets = {
    server = "XXX\XXX",
    Database = "Customer",
    Integrated Security = "True",
    }
    presets.id = "XXX"
    local template = [[
    SELECT
    'Control_Content'
    FROM
    'Customer.dbo.Report_Client_Data'
    WHERE
    'Control_Name' LIKE 'Long_Name' AND 'Client_Id' = 154;
     ]]

    local data, keys = utilities.sql.execute {
    presets = presets,
    template = template,
    variables = {},
    }

I can't seem to find where or how the connection is being made, except
perhaps where utilities.sql.execute is called, but I can't find any
information anywhere about such a call in lua or context...

[-- Attachment #1.2: Type: text/html, Size: 9396 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-26 20:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 16:38 LuaTeX/ConTeXt connect to SQL Server Matt Baker
2014-05-26 19:05 ` Hans Hagen
2014-05-26 19:48   ` Matt Baker
2014-05-26 20:56     ` Hans Hagen
  -- strict thread matches above, loose matches on Subject: below --
2014-05-23 19:47 Matt Baker

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).