Roger Binns <rog...@rogerbinns.com> writes:
> On 04/11/2010 11:09 AM, Nikolaus Rath wrote:
>> Yes, you remember correctly. Actually that would be a perfect solution.
>> But how do I use it? It seems to me that I need to pass some argument to
>> Shell.command_dump(), because the following just produces an empty file:
>>
>>
>> import apsw
>> ofh = open('dump.txt', 'w')
>> db = apsw.Connection('test.db')
>> s = apsw.Shell(db=db, stdout=ofh)
>> s.command_dump('.dump')
>
> That is asking it to dump the tables named '.', 'd', 'u', 'm' and 'p' :-)

I see. I gues I got confused by the help that refers to the parameter as
'cmd':

 |  command_dump(self, cmd)
 |      dump ?TABLE? [TABLE...]: Dumps all or specified tables in SQL text 
format
 |      
 |      The table name is treated as like pattern so you can use % as

 
> I'd suggest the more orthodox way of invoking commands which is less likely 
> to catch you out like this.
>
>    s.process_command(".dump")

That works, thanks! But why is it *that* slow?

[0] vostro:~/tmp$ cat dump.py
import apsw

db = apsw.Connection('test.db')
ofh = open('dump-py.sql', 'w')
s = apsw.Shell(db=db, stdout=ofh)
s.process_command('.dump')

[0] vostro:~/tmp$ cat dump.sh
cat <<EOF | sqlite3 test.db
.output dump.txt
.dump
EOF

[0] vostro:~/tmp$ time python dump.py ; time sh dump.sh

real    2m16.632s
user    2m12.080s
sys     0m3.756s

real    0m13.289s
user    0m9.661s
sys     0m3.600s


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to