Subject Re: [firebird-python] table name in cursor description
Author Uwe Grauer
dwich_cz wrote:
> Hi guys,
> I use FB a lot. I use it with PHP and now I'm switching to Python.
>
> I use a PHP function http://php.net/ibase_field_info which returns
> information about result, such as field's table name. When executing
> SELECT with JOIN, it allows me to see what table is certain field from.
>
> Simplified example with two tables: users (id, name); departments (id,
> name).
> SELECT * FROM users LEFT JOIN departments
> returns one resultset with four columns: id, name, id, name.
>
> With PHP function mentioned above, I can map the result to array like this
> print $data['user']['name']
> print $data['department']['name']
> Quite handy for large SELECTs with multiple JOINs. Each table has it's
> own "namespace".
>
> The question is: Is there any way to retrieve column's table name in
> kinterbasdb? I tried to find it but I couldn't. Thanks for any advice
> as this is would help me a lot.
>

No, not directly.

Python's DBAPI doesn't have a database agnostic way to get field
information for a table.
python DBAPI:
http://www.python.org/dev/peps/pep-0249/

You would have to use database specific functions:
http://www.firebirdfaq.org/faq174/

Uwe