I would definitely not rely upon new Oracle features like GENERATED AS
IDENTITY unless it is absolutely no issue.
The SQL you may emit for using NEXTVAL is along the lines of:
INSERT INTO table (id, col1, col2, ...) VALUES (my_sequence.nextval,
'data1', 'data2', ...)
See the example at
http://docs.oracle.com/cd/A84870_01/doc/server.816/a76989/ch26.htm.
SQLAlchemy supports emitting SQL of this form against the Oracle
backend, and there are many ways to achieve this result depending on
what you are starting with.
What is not clear is what we are inserting. Is this just a list of
dictionaries you'd like to bulk insert into a table? What kind of
Python structure do you have that represents these dynamically created
tables? (choices are: nothing, a Table, or a mapped class).
On 10/1/15 1:11 AM, Nana Okyere wrote:
In my application, atables is dynamically created on the schema. I
need to insert rows onto that table. I tried to use some of the
methods suggested here
<http://gil.browdy.net/build/SQLAlchemy/doc/faq/performance.html#i-m-inserting-400-000-rows-with-the-orm-and-it-s-really-slow> but
then I realized that they are passing the mapped class or the table of
the class to the bulk_insert_mappings method or the
engine.execute(Customer.__table__.insert() method. In both approaches,
Customer is a mapped class. For what I'm doing, the table I'm doing
the insert on is dynamically created. So I can't do models.TableName.
Is there a way to do bulk inserts on such a table in sqlalchey (orm or
core) ?
I tried the "insert all .... select * from dual" construct in oracle
but that doesn't work with sequence_name.nextval for the id column. So
I'm looking for another approach. I read that since oracle 12c I can
create a unique id column using *GENERATED AS IDENTITY *clause. Is
that supported in sqlalchemy? Then I could just insert rows without
worrying about how the id is generated. Thanks for sqlalchemy and your
continued support.
--
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.