>> Will such software extensions become more feasible?
>
> Yes, I think so.
Thanks for such positive feedback.
> The API perhaps would be simple, something like
>
> class SQLObject(...):
> @classmethod
> def createAsSelectSQL(cls, selectFrom):
> ...
How do you think about the clarification for additional classes?
> @classmethod
> def createAsSelect(cls, selectFrom):
> conn = connection or cls._connection
> query = cls.createAsSelectSQL(selectFrom)
> conn.query(query)
>
> where ``selectFrom`` is ``SelectResults`` instance. The method shod
> construct ``CREATE TABLE ... AS SELECT ...`` but it also must construct
> a list of columns (instances of ``col.Col`` classes) and call
> ``cls.sqlmeta.addColumn(columnDef)`` for every column in the list.
Will the determination of involved data structures need any further
software design considerations?
> And here I foresee a problem. It's possible to create a table in the
> database but how to recreate the class with all columns on the second
> run of the program or in another program that will use the class?
Are you used to fiddle with database reflection (or introspection)?
Regards,
Markus
|