New submission from Christoph Burgmer <cburg...@ira.uka.de>:

'PRAGMA database.table_info("SOME_TABLE_NAME")' will report table metadata for 
the given database. The main database called 'main', can be extended by 
attaching further databases via 'ATTACH DATABASE'. The above PRAGMA should 
respect the chosen database, but fails to do so on Win32 (tested on Wine) while 
it does on Linux.

How to reproduce:

FILE 'first.db' has table:

  CREATE TABLE "First" (
          "Test" INTEGER NOT NULL
  );

FILE 'second.db' has table:

  CREATE TABLE "Second" (
          "Test" INTEGER NOT NULL
  );

The final result of the following code shoule be empty, but returns table data 
from second.db instead.

Y:\>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on 
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect('first.db')
>>> c = conn.cursor()
>>> c.execute("ATTACH DATABASE 'second.db' AS 'second'")
<sqlite3.Cursor object at 0x0071FB00>
>>> for row in c:
...     print repr(row)
...
>>> c.execute("PRAGMA 'main'.table_info('Second')")
<sqlite3.Cursor object at 0x0071FB00>
>>> for row in c:
...     print repr(row)
...
(0, u'Test', u'INTEGER', 99, None, 0)
>>>

In contrast sqlite3.exe respects the value for the same command:

Y:\>sqlite3.exe first.db
SQLite version 3.6.23
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
First
sqlite> ATTACH DATABASE 'second.db' AS 'second';
sqlite> .tables
First
sqlite> PRAGMA main.table_info('Second');
sqlite> PRAGMA second.table_info('Second');
0|Test|INTEGER|1||0
sqlite>

Advice on further debugging possibilities is requested. I do not have a Windows 
system available though, nor can I currently compile for Win32.

----------
components: Library (Lib)
messages: 101440
nosy: christoph
severity: normal
status: open
title: SQLite3 PRAGMA table_info doesn't respect database on Win32
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8192>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to