Sebastian: You have what looks (to a non-Postgres user) like a proper ADO connection string for PostgreSQL. Open the Postgres database using adodbapi. I have already done all of the tricky COM stuff for you. You can also open the ACCESS database using adodbapi. There is an example in C:\python{your version number here}\Lib\site-packages\adodbapi\tests\db_print.py . Given that your databases are so completly different, you will most likely need to copy the data field-by-field. I think you will find no pre-packaged move-this-whole-table shortcut for this job. If the Postgres will not work for you, please let me know. I am planning to add Postgres tests and examples to the adodbapi test suite, and have set up a test server, but have not made the time to get further. We could work together on Postgres support. By the way, I disagree with Gerdus. I personally find Python much easier to use than VBA for prototyping and quickie jobs. -- Vernon Cole
On Wed, Jul 29, 2009 at 6:16 AM, Gerdus van Zyl <gerdusvan...@gmail.com>wrote: > Are you trying to copy a table from an access database to a postgres > database? Because that's the impression I get, in which case do you > need to do it once or do you need to do it regularly? In both cases > Python might not be an optimal choice. > You might have more luck using TransferDatabase and ODBC, and first > prototype in VBA then transfer to Python. Also if you could explain > what you are trying to do, we might be better able to help. > > ~Gerdus > > On Wed, Jul 29, 2009 at 10:23 AM, Tim Golden<m...@timgolden.me.uk> wrote: > > [copying back to the list] > > > >> Not sure how to reply to the thread, since I thought that if I reply to > >> "python-win32@python.org" then it would start a new thread? > > > > Replying to python-win32@python.org is the right thing to > > do; the mailing list software should recognise all the > > clues it needs to continue the thread. > > > > > > sebastian.ve...@uk.bnpparibas.com wrote: > >> > >> Hi Tim, > >> > >> I tried this: > >>>>> > >>>>> a = win32com.client.Dispatch("access.application") > >>>>> connStr = 'Driver={PostgreSQL > >> > >> Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings="set TimeZone > to > >> -8; set search_path to pid,public;"' > > > > Well that surprised me: you're using Access as a frontend > > to PostgreSQL? > >>>>> > >>>>> a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb') > >>>>> a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1') > >> > >> but it threw an exception that I couldn't interpret. Can you please > help? > > > > This is obviously tricky with two different databases in the equation, > one > > of them PostgreSQL, but what will be > > most helpful is for you to produce an easily reproducible > > sample which someone else can run, plus the traceback you > > get. Going through this exercise may even cause you to > > track down the problem yourself. In particular, try to > > eliminate external dependencies: try to do the copy table > > thing between two Access databases, or within the same > > one (if that's possible; I haven't used Access in earnest > > for a while now). > > > > TJG > > _______________________________________________ > > python-win32 mailing list > > python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > _______________________________________________ > python-win32 mailing list > python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 >
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32