Thanks Michael for your suggestion. On Wednesday, February 4, 2015 at 8:09:15 PM UTC+5:30, Michael Bayer wrote: > > your tables already exist so stick with BigInteger. Doesn’t make much > difference on the client side. > > > > Anurag Vaishwade <[email protected] <javascript:>> wrote: > > > Hello Everyone, > > I am facing issues with defining table's primary key > column as Numeric(18,0).I am connecting to a MSSQL and in database all > tables are defined as Numeric(18,0) for primary key. > > So to match with the database table schema I updated Sqlalchemy tables > as Numeric(18,0) but I am facing Issues when the table is having an insert > trigger. > > Eg. > > sometable = Table("sometable", > > metadata, > > Column("sometable_id",Numeric(18,0), > primary_key=True)) > > So I gone through the docs and found I need to turn of > implicit_returning=False and optionally need to auto-increment primary_key > so I changed my schema to bellow > > > > sometable = Table("sometable", > > metadata, > > Column("sometable_id", Numeric(18,0), > autoincrement=True,primary_key=True), > > implicit_returning=False) > > But still it throws the bellow error > > {FlushError: Instance <sometable at 0x7f2e8c180090> has a NULL identity > key. If this is > > an auto-generated value, check that the database table allows generation > of new primary key > > values, and that the mapped Column object is configured to expect these > generated values. > > Ensure also that this flush() is not occurring at an inappropriate time, > such as within a load() > > event. > > } > > > > After the issue I found that autoincrement is the problem I went ahead > and changed my table schema to have data type BigInteger for primary key. > > > > sometable = Table("sometable", > > metadata, > > Column("sometable_id", BigInteger, > autoincrement=True,primary_key=True), > > implicit_returning=False) > > > > And it worked fine for all cases including insert triggers as well. > > So my question is what should be the preferred data type for primary > keys in my scenario. > > Do i continue using BigInteger. > > Need suggestions guys. > > > > > > -- > > 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] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > 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.
