if you cd to your web2py/scripts directory and run something like:

python cpdb.py -f ./applications/welcome/databases -F ./dbTest -y
sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ../gluon, it
should work...

my source db has migrate=False, i think that is a must, but Massimo
can confirm that.

Mart :)

On Jul 23, 6:59 pm, mart <[email protected]> wrote:
> oh... i just remembered, we can also use it from the web2py/scripts
> dir and use the 'default' paths (i think)... let me get back with
> this...
>
> On Jul 23, 5:15 pm, mart <[email protected]> wrote:
>
>
>
>
>
>
>
> > yet another addendum:
>
> > to me cpdb.py is just a skeleton, it will copy a DB and all that good
> > stuff, but you can add to it for quick access to tables @ from
> > something like a bash shell...
>
> > as an example, i have a variation on this that uses urllib2 to
> > download full DB's, connects to it and a python console is started in
> > my bash shell that can make use of the 'db' object. So, i can
> > immediately start using the object db.
>
> > i.e. $ print db(db.myTable.name=='a_name').select().last().value
>
> > >>> myField_value
>
> > or, i added some helpers to quickly display entire tables in a nice
> > and readable format (i can do: -table tableName fields=id,name,value
> > file=./myFile.txt
>
> > dal @ the cmd line is a wonderful thing! :)
> > Mart :)
>
> > On Jul 23, 5:03 pm, mart <[email protected]> wrote:
>
> > > addendum:
>
> > > when it has run successfully, you should see an output similar to this
> > > in you shell:
>
> > > dalPath: /Users/mart/aptanaApps/src/blueLite/pyUtils/sql/blueSQL
> > > db.tables: ['affectedFile', 'archive', 'auth_cas', 'auth_event',
> > > 'auth_group', 'auth_membership', 'auth_permission', 'auth_user',
> > > 'buildData', 'buildLogger', 'buildProperties', 'changes', 'clean',
> > > 'cmdObjects', 'commonTags', 'compile', 'createdArchive',
> > > 'cumulativeProperties', 'data', 'deliver', 'deliveryFileset',
> > > 'environment', 'ether', 'exceptionLogger', 'ftp', 'ftpGet',
> > > 'issuekeys', 'jiraIssue', 'local_history', 'local_user', 'mail',
> > > 'p4Properties', 'p4Views', 'package', 'plugin_wiki_attachment',
> > > 'plugin_wiki_comment', 'plugin_wiki_link', 'plugin_wiki_page',
> > > 'plugin_wiki_page_archive', 'plugin_wiki_tag', 'Q', 'scriptCompiler',
> > > 'searchAndReplace', 'sjsCompile', 'status', 'sync']
> > > folder exists: /Users/mart/aptanaApps/src/blueLite/db_storage
> > > creating tables...
> > > exporting data...
> > > importing data...
> > > done!
> > > Attention: do not run this program again or you end up with duplicate
> > > records
>
> > > On Jul 23, 4:58 pm, mart <[email protected]> wrote:
>
> > > > so, cpdb.py runs on its own (no need to invoque with web2py.py).
>
> > > > this is the short version of its usage:
>
> > > > usage: cpdb.py [-h] -f SOURCEFOLDER -F TARGETFOLDER -y
> > > >                   SOURCECONNECTIONSTRING -Y TARGETCONNECTIONSTRING
> > > >                   [-a AUTOIMPORT] -d DAL [-t {True,False}] [-b TABLES]
> > > >                   [-c CLEAN]
>
> > > > you can something like:
>
> > > > $ python cpdb.py -f ./blueLite/db_storage -F ./blueLite/blueP4 -y
> > > > sqlite://storage.sqlite -Y sqlite://storage2.sqlite -d ./blueLite/
> > > > pyUtils/sql/blueSQL
>
> > > > -f points to the folder of the source DB
> > > > -F points t0 the folder of the target DB (which doen't exist yet)
> > > > -y the source connection string
> > > > -Y the target connection string
> > > > -d points to the folder where dal.py lives (like .../gluon
>
> > > > -a is set to True by default
>
> > > > warning:
> > > > -c will delete the source db & tables!
> > > > -t will truncate all tables
>
> > > > i use this within scripts pn a daily basis and all works for me.
> > > > Please try it this way and let me know if you still have issues (i
> > > > have not tested from sqLite to postgres, but if the connection string
> > > > is correct and everything to connect to postgres is on the system then
> > > > all should work well)
>
> > > > Mart :)
>
> > > > On Jul 23, 4:43 am, Massimo Di Pierro <[email protected]>
> > > > wrote:
>
> > > > > Mart wrote it.Let's wait for his opinion first. ;-)
>
> > > > > On Jul 23, 3:26 am, Kenneth Lundström <[email protected]>
> > > > > wrote:
>
> > > > > > I guess we have to wait for maybe Massimo to look into this.
>
> > > > > > Kenneth
>
> > > > > > Hi Kenneth, Yes both the connection strings work in db.py which I 
> > > > > > too
> > > > > > find very puzzling. On Jul 23, 12:24 pm, Kenneth Lundstr m
>
> > > > > > <[email protected]> wrote:
> > > > > > >> It sounds like web2py is not able to open either the sqlite file 
> > > > > > >> or
> > > > > > >> postgres database. Have you tried to use both connection strings 
> > > > > > >> in a
> > > > > > >> model file to test that both works?
>
> > > > > > >> Kenneth
>
> > > > > > >>> I am having a hard time migrating data from sqlite to postgres
> > > > > > >>> This is the command that I use
> > > > > > >>> ./web2py.py -S testapp -M -N -R scripts/cpdb.py -A -f
> > > > > > >>> sqlite://applications/testapp/databases/storage.sqlite -y 
> > > > > > >>> 'sqlite://
> > > > > > >>> applications/testapp/databases/storage.sqlite'  -Y 'postgres://
> > > > > > >>> puser:ppass@localhost/testdb'
> > > > > > >>> It says
> > > > > > >>> web2py Web Framework
> > > > > > >>> Created by Massimo Di Pierro, Copyright 2007-2011
> > > > > > >>> Version 1.97.1 (2011-06-26 19:25:44)
> > > > > > >>> Database drivers available: SQLite3, pymysql, PostgreSQL
> > > > > > >>> EXCEPTION: could not make a copy of the database
> > > > > > >>> Failure to connect, tried 5 times:
> > > > > > >>> unable to open database file
> > > > > > >>> Any idea how to make this work?

Reply via email to