Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello,

I have a kind of a backup solution that requires parsing for certain case (mysql insert statement).

Currently this is implemented with Parse::RecDescent as it took me some while to get feet wet with its grammars. But the parser seems to be the performance bottleneck so recently I decided to try the brand new Marpa::XS and it cracked my nut head to make it work for me.

I am still very sure it should be the right tool for the case but just see no any (simple) explanation on how to turn the single line of input into the data structure ( arrayref of arrayrefs ). E. g.,:

INSERT INTO `tehtable` ( `field00`, `field01` ) VALUES ( 123, `abcd\'e +fgh` );
into arrayref like this:
[ [ qw/field00 field01/ ], [ 123, 'abcd\'efgh' ] ]

I can see the Marpa::HTML code but it's not that explanarory yet to me since it's about much more complicated than what I need, e. g. it does use that mysterious BNF stuff that I'm very unsure I will need for that particular task.

Marpa's 'Calculator' example isn't useful for me neither because it takes input token by token. Does it mean to me that I need to split my INSERT statement by myself for Marpa's input?

I have also tried with SQL::Translator but it seems to parse only the database schemas, e. g., CREATE TABLE only. Am I wrong on that?

Thank you.


In reply to Marpa::XS for SQL INSERTs? by petr999

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-24 00:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found