How to clear the crap initial data?

37 views
Skip to first unread message

Marko Poutiainen

unread,
Jan 16, 2016, 1:41:36 PM1/16/16
to web2py-users
Sorry for the rude topic but I have just spent an hour on something so mindbogglingly stupid it makes my blood boil.

Why does web2py create those stupid useless rows in my database that I have to clean by hand?

Why does telling the delete confirmation not to bother me make the whole delete checkbox to stop working? (Yes, I clicked it and now if I try to select it it unsets automatically.) So I can't remove them by hand.

How am I supposed to clean the database (and why the heck do I need to do it in the first place??)? I have tried db.table.truncate() in table's administration panel -> nothing happens. Where am I supposed to do that?

Yes, this is definitely something I want to do on a Saturday evening...

This is the stuff I see in my db and I'm pretty sure I didn't add this:


Semnopithecus...Daughter-cell...Violet will b...Nerve-fibres ...Respective bo...Family spawn ...Nowhere do so...Tartan; but t...Reconstructio...Timber for it...263 professor...True2016-01-16 19:37:08None2016-01-16 19:37:08None
4Standing out ...Healthfulness...Rigel 466 sir...Outdated equi...Cambrian peri...Heavy as if e...Vedda of monk...O as the broa...Regulated the...Trillion mile...Oval. Evoluti...True2016-01-16 19:37:08None2016-01-16 19:37:08None
5Graphite simi...Next great sc...Uganda bug ac...Fountain of m...Seven-weeks-o...Wood-cock whi...Emotions. The...I the primate...Sand-grouse i...Emotions such...Legacy of a f...True2016-01-16 19:37:08None2016-01-16 19:37:08None
6Ages--for bri...Silly ants ar...Reward of hea...Found in orde...Negroes and t...Disguise diff...Diaphragm cam...Contracting m...Terms of life...Discontinuous...1.d. Russell ...True2016-01-16 19:37:08None2016-01-16 19:37:08None
7Variable befo...Serves as wel...Beautiful exp...Depends. sepa...Stuck togethe...Afford a new ...Supplemented ...Incident is a...Deny a good i...Unenforceabil...Exaggerate th...True2016-01-16 19:37:08None2016-01-16 19:37:08None
8Orionis showi...Hoofed mammal...Fishermen who...Cohesion of s...Pays an illus...Peopled than ...Universe. our...Inconceivably...Environment. ...Nest in their...501 c. Above ...True2016-01-16 19:37:08None2016-01-16 19:37:08None
9Lancelets and...Infects him h...Distinctive s...Slippery brid...Facilitates t...Canal round i...Travel rapidl...Scharff r. It...Elder brother...Do not in ken...Cools to lang...True2016-01-16 19:37:08None2016-01-16 19:37:08None
10Sloth s eyes....
Efforts and t...Unpromising h...I.e. We have ...Field-voles p...Average of sm...Jewels. there...Refused to 26...Practical int...Abdomen--for ...Branch to par...True2016-01-16 19:37:08None2016-01-16 19:37:08None

Marko Poutiainen

unread,
Jan 16, 2016, 1:49:37 PM1/16/16
to web2py-users
What the bleeping bleep bleep? Even with sqlite3 web2py keeps creating this crap again and again. I delete and open the admin page again and the table again has this crap?

Jim S

unread,
Jan 16, 2016, 2:10:38 PM1/16/16
to web2py-users
What does your code look like? 

Web2py isn't going to do this on its own.  Do you have have code similar to this someone in your db.py or controller?

from gluon.contrib.populate import populate
populate(db.mytable_name_here,100)
-Jim

Jim S

unread,
Jan 16, 2016, 2:12:39 PM1/16/16
to web2py-users
Also, what database are you using?  There are plenty of tools available to do direct data manipulation to get rid of those unwanted records really quickly and easily.

MySQL - I use SQLyog - look for the community version
Sqlite - I use the SQLite Manager Firefox addon

-Jim

Marko Poutiainen

unread,
Jan 16, 2016, 2:49:23 PM1/16/16
to web2py-users
Ah, yes, I have that when I grepped the code. I must have copied it from somewhere when I wrote the code (probably some example that I used).

The strange thing was that when I cleared auth_user this was run again, but not when I did it to another table.

I did manage to clean the database by first adding a new user to auth_user, then using sqlite3 to delete everything else from that and clean the other affected table. If I didn't add it, for some reason the tables were populated again.

Marko Poutiainen

unread,
Jan 16, 2016, 2:54:51 PM1/16/16
to web2py-users
No wonder this kept happening as I had this code in db_wizard_populate.py:

from gluon.contrib.populate import populate
if db(db.auth_user).isempty():
     populate(db.auth_user,10)
     populate(db.t_kiinnostuneet,10)

Can I just delete the entire file? I wrote this particular app a few years ago and just needed to deploy it so my memory on specifics is a bit hazy...

Anthony

unread,
Jan 16, 2016, 2:56:23 PM1/16/16
to web...@googlegroups.com
How am I supposed to clean the database (and why the heck do I need to do it in the first place??)? I have tried db.table.truncate() in table's administration panel -> nothing happens. Where am I supposed to do that?

Well, you can simply call .truncate right in your app code if you'd like (in a model or controller). Of course, you'd want to make it conditional somehow or disable/remove the code once you're done truncating.

Otherwise, you can always start a web2py shell and do it from there.
 
This is the stuff I see in my db and I'm pretty sure I didn't add this:
Ah, yes, I have that when I grepped the code. I must have copied it from somewhere when I wrote the code (probably some example that I used).

Oops. ;-)

Anthony

Jim Steil

unread,
Jan 16, 2016, 2:57:47 PM1/16/16
to web...@googlegroups.com
Like I said before, web2py isn't going to auto-populate your db unless you explicitly tell it to do so.  There isn't any magic going on here.  I'd search your codebase to make sure you've found all the places where populate may have been used.

-Jim

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/M3r9P6gBlW4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages