To avoid incurring in overhead on every request you could use a script to
be called once with web2py.py -R option.
Also you could create a function in a model file with little overhead:
def create_indexes():
db.executesql('CREATE INDEX...')
later you can call it manually from the shell
yes, you have a nice trick on your code, thanks so much massimo
e.g.
# -*- coding: utf-8 -*-
# index
def index():
filename = os.path.join(request.folder, 'databases', 'idx_tables.index')
if not os.path.exists(filename):
# create index : auth_user
db.executesql('CREATE INDEX idx_auth_user ON auth_u
thanks so much for the nice trick, create the file on web2py databases
folder after execute 'CREATE INDEX'
pardon, i think it's not efficient, pls imagine if there are a lot of
tables, and execute the controllers/install.py to have a lot of conditional
check for each file for each table that hav
OK than you want something like:
filename = os.path.join(request.folder, 'databases',
'idx_auth_user.index')
if not os.path.exist(filename)
db.executesql('CREATE INDEX idx_auth_user ON auth_user (id, first_name,
last_name, email, username);')
open(filename).write(da
thanks all, that can do, but CREATE INDEX IF NOT EXISTS, it's not work in
mysql (pls correct me if i'm wrong), so i use the universal code that can
cover all of it, of course i think i can create conditional for check for
the database connection base on environment.
in my environment are
- devel
It is simply possible that line is created multiple times. Add a print
request before the index() function to check.
The second time it is called the index exists already.
In SQLITE you can do
CREATE INDEX IF NOT EXISTS
On Friday, 8 July 2016 19:47:42 UTC-5, 黄祥 wrote:
>
> let say i have a
On Friday, July 8, 2016 at 8:12:39 PM UTC-7, 黄祥 wrote:
>
> the apps is build from scratch, no created index before either from apps
> and from database side. the only place i create index is in the
> controllers/install.py, and it's only execute one time only.
>
> my logic during first code ins
the apps is build from scratch, no created index before either from apps
and from database side. the only place i create index is in the
controllers/install.py, and it's only execute one time only.
my logic during first code install script is :
execute create index first then execute insert tabl
On Friday, July 8, 2016 at 6:31:29 PM UTC-7, Marlysson Silva wrote:
>
> The keys of dictionary of bulk_insert are fields of table that you want
> you insert.
> Try so:
>
> db.bank.bulk_insert([ {'name' : 'bank0', 'website' : 'http://www.bank0.com
> '}, {'name' : 'bank1', 'website' : 'http://www
The keys of dictionary of bulk_insert are fields of table that you want you
insert.
Try so:
db.bank.bulk_insert([ {'name' : 'bank0', 'website' : 'http://www.bank0.com'
}, {'name' : 'bank1', 'website' : 'http://www.bank1.com'}, ] )
Em sexta-feira, 8 de julho de 2016 21:47:42 UTC-3, 黄祥 escreveu:
On Friday, July 8, 2016 at 5:47:42 PM UTC-7, 黄祥 wrote:
>
> let say i have a code:
> *models/db_wizard_1_bank.py*
> db.define_table('bank',
> Field('name'),
> Field('website'),
> format = '%(name)s')
>
> *controllers/install.py*
> def index():
> if db(db.auth_permission).isempty() and db(db.aut
11 matches
Mail list logo