On 12/27/2015 10:48 AM, Philip Martin wrote:
> I am integrating a new data source that provides schema data and
> versioning in text files.  The schema is comprised of several
> sub-schemas, and overall, contains over 250+ tables.  The data model is
> actually very good, with lots of skinny tables/normalized properly.
> 
> The schema dialect for data loading is in Oracle, and I am going to
> insert it into a Postgresql database.
> 
> I have the following parsed into a pure python namedtuple structure with
> something like:
> 
> 
> TablePreparer
> : relative data path
> : columns
> : primary keys
> : foreign keys
> 
> Columns:
> : name
> : data_type
> : nullable
> 
> 
> An example column would look like: Column(name='country_name',
> data_type='VARCHAR(20)', nullable=False, description='Name of the ISO
> country.')
> 
> For the most part, the Oracle->Postrgresql types are one to one mapping.
>  I don't really care about the ORM component of SqlAlchemy, but rather
> the mapping/migration aspects.
> 
> I spent a day looking through the source code, but it seems like any ddl
> parsing functionality is buried deep into the code.  If someone could
> point me to where I could access something to parse the example column
> into the Column('country_name', String(20), nullable=False)

There's no general use DDL or SQL string parsing functionality in
SQLAlchemy - parsing of DDL/SQL in general is not one of its offered
features.   There *is* the table/column reflection feature however which
does retrieve from the database in a backend-specific way that a certain
column is for example VARCHAR(20).  But it's not necessarily using
string parsing to do that, different databases make the type name and
the arguments available in different ways.

Parsing the type strings that you're dealing with is likely something
you can solve easily using some local regular expressions that deal with
the type strings you care about.




> 
> Thanks for the help.  I appreciate it.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlalchemy+unsubscr...@googlegroups.com
> <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
> To post to this group, send email to sqlalchemy@googlegroups.com
> <mailto:sqlalchemy@googlegroups.com>.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to