gavo.grammars.mysqldumpgrammar module

A q’n’d grammar for reading MySQL dumps of moderate size.

class gavo.grammars.mysqldumpgrammar.MySQLDumpGrammar(parent, **kwargs)[source]

Bases: Grammar, FileRowAttributes

A grammar pulling information from MySQL dump files.

WARNING: This is a quick hack. If you want/need it, please contact the authors.

At this point this is nothing but an ugly RE mess with lots of assumptions about the dump file that’s easily fooled. Also, the entire dump file will be pulled into memory.

Since grammar semantics cannot do anything else, this will always only iterate over a single table. This currently is fixed to the first, but it’s conceivable to make that selectable.

Database NULLs are already translated into Nones.

In other words: It might do for simple cases. If you have something else, improve this or complain to the authors.

attrSeq = [<gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.BooleanAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.complexattrs.StructAttribute object>, <gavo.base.parsecontext.OriginalAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.complexattrs.PropertyAttribute object>, <gavo.rscdef.common.RDAttribute object>, <gavo.base.complexattrs.StructListAttribute object>, <gavo.base.complexattrs.StructAttribute object>]
clearProperty(name)
completedCallbacks = []
getFullId()
getProperty(name, default=<Undefined>)
hasProperty(name)
managedAttrs = {'enc': <gavo.base.attrdef.UnicodeAttribute object>, 'gunzip': <gavo.base.attrdef.BooleanAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'ignoreOn': <gavo.base.complexattrs.StructAttribute object>, 'original': <gavo.base.parsecontext.OriginalAttribute object>, 'preFilter': <gavo.base.attrdef.UnicodeAttribute object>, 'properties': <gavo.base.complexattrs.PropertyAttribute object>, 'property': <gavo.base.complexattrs.PropertyAttribute object>, 'rd': <gavo.rscdef.common.RDAttribute object>, 'rowfilter': <gavo.base.complexattrs.StructListAttribute object>, 'rowfilters': <gavo.base.complexattrs.StructListAttribute object>, 'sourceFields': <gavo.base.complexattrs.StructAttribute object>}
name_ = 'mySQLDumpGrammar'
property rd
rowIterator

alias of RowIterator

setProperty(name, value)
class gavo.grammars.mysqldumpgrammar.RowIterator(grammar, sourceToken, **kwargs)[source]

Bases: FileRowIterator

gavo.grammars.mysqldumpgrammar.guessFieldNames(dump)[source]

returns the table name and the column names for the first CREATE TABLE statement in a MySQL dump.

gavo.grammars.mysqldumpgrammar.makeRecord(fieldNames, fieldValues)[source]

creates a rawdict for fieldValues

This function should undo any quoting introduced by MySQL. It doesn’t right now since we’re not working from actual docs.