yhat / db.py

db.py is an easier way to interact with your databases
BSD 2-Clause "Simplified" License
1.22k stars 111 forks source link

Postgres schemas are not supported #56

Open jlowin opened 9 years ago

jlowin commented 9 years ago

db.py will identify all tables across all tables, but can't query them because it only tries to access the unqualified table, without the schema prepended.

For example, if I have a schema s and a table t, calling db.all() tries to execute SELECT * FROM t instead of SELECT * FROM s.t. Unless users have configured a postgres search_path (and have unambiguous table names) this query will fail.

emiliom commented 9 years ago

Ran into the same issue. For schemas that are not in the search_path, tables are identified and can be described, but its methods fail b/c the sql select statement that's composed does not qualify table names with a schema name. For example, for table mytable that's not in a schema in the search_path, db.tables.mytable.count fails with this error:

DatabaseError: Execution failed on sql 'select * from mytable;': relation "mytable" does not exist

Any workarounds or tricks? Thanks.

emiliom commented 8 years ago

Does this commit address the schema problem reported in this issue? I haven't tested it, but it'd be helpful to know if the problem is resolved.