python: Session from mysql save as xml?
Chris Stoughton
chris.stoughton at gmail.com
Tue May 10 08:04:10 EDT 2016
Sorry that the question was not clear. The source in this example is in a
mysql database.
On Tue, May 10, 2016 at 6:54 AM, Mike Evans <mikee at saxicola.co.uk> wrote:
> On Mon, 9 May 2016 16:17:55 -0700 (PDT)
> stoughto <chris.stoughton at gmail.com> wrote:
>
> > I would like to run a script to backup a a gnucash book, using python:
> >
> > from gnucash import *
> > session = Session("mysql://username:password@localhost/gnucash")
> > saveFileName = "backup-12345.xml"
> > session.saveAs(saveFileName)
> >
> >
> > The method I am missing is "Session.saveAs(fileName)"
> >
> > Does such a thing exist, or if not, can someone suggest how to implement
> > such a thing?
> >
> > This does not have to be a method of the class Session. Filling in the
> > details of this function def would work just as well:
> >
> > def saveSessionToFile(session, fileName):
> > # open the xml file
> > # write the session to it
> > # close whatever needs to be closed
> > return
> >
> > Thank you
> >
> >
> >
>
> Why do it that way? If you just want to backup your file do:
>
> from shutil import copyfile
>
> copyfile(src, dst)
>
> Mike E
>
>
> --
> PGP key:
> http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x00CDB13500D7AB53
>
More information about the gnucash-user
mailing list