Re: Cannot write tables to .accdb database from arcpy

1323
8
05-22-2014 07:58 AM
WalterPeterson
New Contributor
I've been after some help for two days now..

Still have not found and example that will work for me..

Use Py to get a table from MS ACCESS, clip, join and return the result in a new table.

Walt.
Tags (2)
0 Kudos
8 Replies
RDHarles
Occasional Contributor
I've been after some help for two days now..

Still have not found and example that will work for me..

Use Py to get a table from MS ACCESS, clip, join and return the result in a new table.

Walt.


Python examples are at the bottom of each the following pages...

get a table from MS ACCESS:
http://resources.arcgis.com/en/help/main/10.2/index.html#//001200000027000000

clip:
http://resources.arcgis.com/en/help/main/10.2/index.html#//000800000004000000

join:
http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000064000000

return the result in a new table:
http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000035000000
0 Kudos
JamesCrandall
MVP Frequent Contributor


get a table from MS ACCESS:
http://resources.arcgis.com/en/help/main/10.2/index.html#//001200000027000000


There is no direct way to reference an MS Access Table to run thru the TableToTable_conversion method (I didn't notice it in the doc).  Well, at least it didn't work for me just now -- I wonder if this has to do with 64bit and Access Drivers related issues?  Anyway, I get a 000732: Input Rows not supported error.  Or maybe I am simply not understanding the method and incorrectly applying it below.


intab = r'C:\TestAccessDB\Testdb.mdb\TestTable'
wsout = r'H:\Documents\ArcGIS\Default.gdb'
arcpy.TableToTable_conversion(intab, wsout, "WindOUT")

0 Kudos
RDHarles
Occasional Contributor
There is no direct way to reference an MS Access Table to run thru the TableToTable_conversion method (I didn't notice it in the doc).  Well, at least it didn't work for me just now -- I wonder if this has to do with 64bit and Access Drivers related issues?



My mistake, I read it as MS Excel...instead of MS Access.
0 Kudos
JamesCrandall
MVP Frequent Contributor
My mistake, I read it as MS Excel...instead of MS Access.


I haven't implemented it, but there is always the pyodbc library to grab the table(s)!
0 Kudos
RDHarles
Occasional Contributor
There is no direct way to reference an MS Access Table to run thru the TableToTable_conversion method (I didn't notice it in the doc).


OK this is strange...it IS actually an option (in red below) in the doc and works if you use the tool from the toolbox, but I can't get it to work in a script...???
import arcpy, os
arcpy.env.workspace = os.getcwd()
arcpy.TableToTable_conversion('NP.mdb/myTable', 'NFG.gdb', "outTable")

Usage

  • This tool supports the following table formats as input:


    • dBASE (.dbf)

    • Comma Separate Value (.csv)

    • tab delimited text (.txt)

    • INFO

    • VPF

    • OLE database

    • personal, file, or SDE geodatabase

    • in-memory table views

0 Kudos
WalterPeterson
New Contributor
Well,   All thank you, but I'm not making much progress:

My target is:

D:/WRP_CIDNE/CIDNE4_DEV.accdb

The table in this database is "KDHR".

After clip&join I want the table to be in the same database named "TAGGED".

Walt.
0 Kudos
T__WayneWhitley
Frequent Contributor
Walt, in order to better service your question, can you start a new thread?  Rephrase your question and include more details:  your system info (which version of ArcGIS, your OS and whether 32 or 64 bit) and if possible attach some sample data.

And just to clarify, when you say you have an accdb table, this doesn't sound like data that is 'spatially enabled' - you can't use a geoprocessing operation such as 'clip' on just a table...but you can do something like join to something else already spatially enabled, maybe make some sort of selection, and clip the result to create an output that perhaps you can copy rows from in order to create just a table (no spatial attributes).  However, lacking details, it isn't clear if you've established read-access to your accdb to begin with.

ArcGIS can 'piggyback' on the Access db format and use geodatabases with the mdb file extension - but this isn't read/write in quite the same way (nor is it recommended) in Access as it is in ArcGIS.  Do you indeed have an mdb geodatabase or is your source data created/maintained in Access?

PS - Welcome to the forums!
0 Kudos
curtvprice
MVP Esteemed Contributor
Well, at least it didn't work for me just now -- I wonder if this has to do with 64bit and Access Drivers related issues? 


arcpy 64 bit (background processing) does not support read or write to personal geodatabase (.mdb). There are other limitations too, documented in the help.

You can read and write to .mdb using 32-bit arcpy -- but .mdb files accessed in this way should not be opened using MS Access, as the geodatabase workspace tables are easily damaged.

You can read and write Access 2007(.accdb) databases (through ODBC drivers).
Arc 10.2 help: Connecting to a 2007 Microsoft Access database (.accdb) in ArcGIS
0 Kudos