This is one of the reasons I'm dropping MySQL, at the end it just generates trouble..
I was hoping to get an easy "two platform" fix for this, but there just is not. So moving to PG needs to done quickly here. Thing is I want PG to be installed on my Workstation, exactly like on Lion Server…. more work Thank you Michael! Martijn On Jan 17, 2012, at 02:29 , Michael Bayer wrote: > > On Jan 16, 2012, at 5:14 PM, Martijn Moeling wrote: > >> I am planning on using PG for production but for now I'm stuck on Mysql. >> >> Mysql does not seem to support Sequence.. >> >> can't I just do x = Column(Integer, autoincreament=True) >> >> Would that work on both? I cannot test PG just jet. > > > MySQL's autoincrement feature only works on a single integer primary key > column and only when INSERT happens. > > mysql doesn't have a lot of option here, you can use a sequence table, a > table with just one row/column that you increment, or the dreaded "select > max(n) from table" - neither of these work very well in a high concurrency > situation. > > If you wanted to go crazy, MySQL supports stored procedures, maybe you could > make a stored procedure that uses the sequence table and acts like a > sequence. Maybe there's one on the web somewhere. > > > > > >> >> On Jan 16, 2012, at 5:07 PM, Michael B >> >> ayer wrote: >> >>> >>> On Jan 16, 2012, at 6:29 AM, Martijn Moeling wrote: >>> >>>>> >>>>> Now I need to import data from the current production system. This data >>>>> already has Serialnumbers generated. >>>>> >>>>> What should I do to make this work? Do I need the sequence created after >>>>> the Import and set the Start value to the last imported SerialNumber+1 ? >>>>> I would prefer creating the sequence before the import and "Update" the >>>>> Sequence after the import. >>> >>> you can create the sequence with a start value if you pass "start=X" to >>> Sequence(). Or you can just bump it up with nextval(). Or PG allows you >>> to call setval() on it. You can pretty much set it to anything at at any >>> time. http://www.postgresql.org/docs/9.1/static/functions-sequence.html >>> >>> If you want to have things created before you deal with import data, then >>> just bump up the sequence as you go through your data. Assigning to >>> SerialNr on the Order will have the effect of not using the Sequence on >>> insert. Also the create_all() step will create the Sequence construct in >>> the DB also. >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "sqlalchemy" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/sqlalchemy?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/sqlalchemy?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
