Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
NewbieXcellence
Starting Member
2 Posts |
Posted - 2009-12-16 : 09:58:52
|
Hi, new to the forum here, hoping you folks might be able to shed some light on a snag I have hit with accessing my companies database using a python program. The code so far looks like this:import dbi, odbcCon = odbc.odbc("DSNname/username/password")Cursor = Con.cursor()Cursor.execute("SELECT * FROM RSID")Results = Cursor.fetchall()When it tries to 'select' the data from the database I get an error: "progError: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'RSID'. in EXEC". Now, I know that I can import the data from this table into Excel so it does exist!!Can anyone tell me if I'm doing something wrong here in my SQL portion of the code at least, if not some mistake with the python portion??If I change the Cursor.execute line above to this bit of code I found on the net:Cursor.execute("SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'")I get an object back with which prints out like this:[(u'tsiprod', u'dbo', u'dtproperties', u'BASE TABLE'), (u'tsiprod', u'tsi', u'APAC', u'BASE TABLE'), etc , etc, etc, .....]. The table I am looking for and many others I recognize as tables appear as the third element of the lists within this list so why can't I access these tables when they do seem to exist and I appear to be connected?? Thanks for any thoughts on this!!!!"Umm maybe I'm probably doing it wrong?" |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-12-16 : 10:48:21
|
| Assuming you have all the necessary permission and that the coneection string is defined correctly, try naming the table with all its parts, e.g., [DatabaseName].[ObjectOwner].RSIDJimEveryday I learn something that somebody else already knew |
 |
|
|
NewbieXcellence
Starting Member
2 Posts |
Posted - 2009-12-16 : 11:02:00
|
| Thank you Mr. Jim that seems have gotten me in there - it wanted the form "[owner].RSID" so I guess it knew the database name. Thanks so much I have been hung up on this for days THANK YOU!!!!!!!!!!!!!!"Umm maybe I'm probably doing it wrong?" |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-12-16 : 11:19:09
|
| You're welcome!Everyday I learn something that somebody else already knew |
 |
|
|
|
|
|
|
|