From: Brent S. E. <we...@ai...> - 2009-04-06 15:58:27
|
It looks to me like the file that the command writes to is on the server machine. Whereas when I just run the export command from the command line I can write to my client machine. The only access I have to the server machine is db2 access. So, the only directory I can write to using the admin_cmd is /tmp on the server which doesn't do me much good. I have changed my python code to fetch all of the records and then manually write the data to the file where I want it on the client machine. Thanks, Brent On Mon, 2009-04-06 at 17:02 +0200, len...@la... wrote: > > So how do I use the admin_cmd procedure from pydb2? > > Never tried it myself so I made up a rather silly example. Note how one > have to quote string literals inside the sql string sent to admin_cmd: > > [db2inst1@wbv9 ~]$ rm -f /tmp/TT.ixf > [db2inst1@wbv9 ~]$ cat admin_cmd_example.py > #!/usr/bin/python > > import DB2 > import sys > > dbname = sys.argv[1] > username = sys.argv[2] > passwd = sys.argv[3] > > conn = DB2.connect(dsn=dbname, uid=username, pwd=passwd) > > c1 = conn.cursor() > c1.execute("call sysproc.admin_cmd('export to /tmp/TT.ixf of ixf select x > from lateral(values (''a'')) T (x)')") > for row in c1.fetchall(): > print row > > > [db2inst1@wbv9 ~]$ ./admin_cmd_example.py <yourdb> <youruser> <yourpasswd> > (1L, None, None) > [db2inst1@wbv9 ~]$ ls -l /tmp/TT.ixf > -rw-r--r-- 1 db2fenc1 db2fadm1 2768 Apr 6 16:57 /tmp/TT.ixf > > > HTH > /Lennart > > > ------------------------------------------------------------------------------ > _______________________________________________ > PyDB2-discuss mailing list > PyD...@li... > https://lists.sourceforge.net/lists/listinfo/pydb2-discuss |