[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-10 Thread mdipierro
If you have the setup, give it a try. On Jun 10, 6:59 pm, Thadeus Burgess wrote: > Idea: > > Theoretically speaking of course if I were to create a virtual > machine loaded with an apache instance and web2py on mod_wsgi. Using > the various methods of *faking* an autonumber field on different

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-10 Thread Thadeus Burgess
Idea: Theoretically speaking of course if I were to create a virtual machine loaded with an apache instance and web2py on mod_wsgi. Using the various methods of *faking* an autonumber field on different virtual machines, for the sake of scientific research. Using the apache AB testing upon a

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread Thadeus Burgess
Understood. I will test this ASAP. -- Thadeus On Wed, Jun 9, 2010 at 11:05 AM, mdipierro wrote: > This is not going to stay, it is just for you to look at. > Consider defining the field as integer and create a trigger using SQL > to autofill this field. > > On Jun 9, 10:52 am, mdipierro wro

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread mdipierro
This is not going to stay, it is just for you to look at. Consider defining the field as integer and create a trigger using SQL to autofill this field. On Jun 9, 10:52 am, mdipierro wrote: > well, I am posting in trunk a modifiled sql.py that > > allows Field('name','autoincrement') and generates

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread mdipierro
well, I am posting in trunk a modifiled sql.py that allows Field('name','autoincrement') and generates the following code for postgresql (only postgresql). Give it a try. Massimo On Jun 9, 10:38 am, Thadeus Burgess wrote: > Postgres > > CREATE TABLE foo ( > id integer PRIMARY KEY SERIAL, > bar

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread Thadeus Burgess
Postgres CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT SERIAL); Or... CREATE SEQUENCE seq_foo_did START 2; CREATE TABLE foo ( id integer PRIMARY KEY SERIAL, bar varchar, did integer DEFAULT nextval('seq_foo_did')); SQLite however does not support multi

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread mdipierro
On a second thought of this matterthis is nonsense. If a table has two autoincrement fields ("id" and "other") they always contain the same values or values that differ for a constant offset (If the started with different values). That is why some database backends probably do not even support

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread mdipierro
I am not sure about the postgresql solution. Tell me how you do it in SQL and i tell you how to do in web2pyese. On Jun 9, 9:01 am, Thadeus Burgess wrote: > Great. What about sqlite? > > -- > Thadeus > > On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > > In postgresql you get it native: > > >

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread mdipierro
I am testing this (both sqlite and postgresql). How do you do it in raw sql? This does not work in sqlite sql CREATE TABLE a( id INTEGER PRIMARY KEY AUTOINCREMENT, d CHAR(512), b INTEGER AUTOINCREMENT ); It does not seem to like two AUTOINCREMENT fields (which is what I thought). O

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread Thadeus Burgess
Great. What about sqlite? -- Thadeus On Wed, Jun 9, 2010 at 8:41 AM, mdipierro wrote: > In postgresql you get it native: > > Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY > KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) > > On Jun 9, 5:28 am, Thadeus Burgess wrote: >> T

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread mdipierro
In postgresql you get it native: Field('yourtfield',SQLCustomType('integer','SERIAL PRIMARY KEY',encoder=(lambda x: int(x)),decoder=(lambda x:x))) On Jun 9, 5:28 am, Thadeus Burgess wrote: > That is the thing, its *almost* the same, but its not a true postgres > sequence. Postgres already has ma

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-09 Thread Thadeus Burgess
That is the thing, its *almost* the same, but its not a true postgres sequence. Postgres already has many years of development making sure their auto number works, why can't I just use that instead of trying to hack around the limitations of a system? I don't have a choice. I *must* have native su

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-08 Thread mdipierro
If it were possible to do a SQL insert without the dummy filed this almost the same as creating a sequence. web2py can create a table without any field but the "id", but I do not do not how to do an insert without any field value. On Jun 8, 8:12 pm, Thadeus Burgess wrote: > This *might* work. You

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-08 Thread Thadeus Burgess
This *might* work. You are right, it is still horrible... It might be *effectively* accomplishing the same thing that sequences do on PostgreSQL, however I still wouldn't use it in production as it feels "hacky". I already have to re-design this table, so I might as well do it 100% right. I never

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-08 Thread mdipierro
I know this horrible but it does solve some of the problems... db.define_table('whopper_seq',Field('dummy')) db.define_table('yourtable',... Field("whopper_id", "integer",compute=lambda r: db.whopper_seq.insert(dummy=None)) ...) On Jun 7, 8:29 pm, Thadeus Burgess wrote: > I have a problem. > >

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-08 Thread mdipierro
On Jun 7, 11:39 pm, Thadeus Burgess wrote: > Legacy systems =) The database was already in place as this, > unfortunately when I migrated from access to postgres I kept the same > schema as I was under a time crunch to get *something* running And > now it bites me in the butt. > > The thing

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-07 Thread Thadeus Burgess
By the way, this is for PostgreSQL that I need this. I think that autoincrement needs to be implemented for each database type natively. The *other* guys have autoincrement already... curious as to why it is left out of web2py. As always, the sooner the better >.< -- Thadeus On Mon, Jun 7,

Re: [web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-07 Thread Thadeus Burgess
Legacy systems =) The database was already in place as this, unfortunately when I migrated from access to postgres I kept the same schema as I was under a time crunch to get *something* running And now it bites me in the butt. The thing is... I cannot do this ``db(db.table.id==3).update(db.tab

[web2py] Re: Advice, convert from string storing numbers to autoincrement integer

2010-06-07 Thread mr.freeze
I'm not even going to ask how you got in this situation :) Could you?: 0) Create a patch to Field for an autoincrement field type 1) Create a new table (whopper_temp) on your database with an id field that is NOT set to auto-increment (yet) 2) Copy all records from the table in question to whopper