My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 43: foreignKeys() doesn't work
1 person starred this issue and may be notified of changes. Back to list
Status:  NoFix
Owner:  ----
Closed:  Apr 2009


 
Reported by vgarnash...@gmail.com, Apr 2, 2009
What steps will reproduce the problem?
1. Create database from attached scripts.
2. Run appropriate (MSQQL or MySQL) attached python scripts.

What is the expected output? What do you see instead?
Expected: List of tables and foreign keys.
Instead: Just list of tables.

What version of the product are you using? On what operating system?
WinXP Prof SP3 
Python 2.6.1
pyodbc:
  pyodbc-2.1.1.win32-py2.6.exe, or
  pyodbc-2.1.2.win32-py2.6.exe, or
  pyodbc-2.1.3.win32-py2.6.exe  
SQL Server 2005 Express, or
MySQL 5.0.67 + mysql-connector-odbc-3.51.27

Please provide any additional information below.


init-mssql.sql
511 bytes   View   Download
init-mysql.sql
351 bytes   View   Download
test-mssql.py
596 bytes   View   Download
test-mysql.py
516 bytes   View   Download
Apr 19, 2009
Project Member #1 mkleehammer
Excellent tests.  The issue is you are calling foreignKeys for the wrong table.  

The first parameter is the primary-key table.  The SQLForeignKey documentation is a
bit confusing: http://msdn.microsoft.com/en-us/library/ms709315.aspx

You can either search using "test2":

  for row in conn.cursor().foreignKeys("test2", params['db'], ""):

Or (more likely what you want), use the foreignTable keyword parameter:

  for row in conn.cursor().foreignKeys(foreignTable="test1"):

The parameters (see foreignKeys in https://code.google.com/p/pyodbc/wiki/Cursor) are
in the same order as the MSDN ODBC documentation, so that might help.
Status: Invalid
Nov 21, 2010
Project Member #2 mkleehammer
(No comment was entered for this change.)
Status: NoFix

Powered by Google Project Hosting