that was pretty trivial so a fix is committed for 0.9 and 0.8 in the latest revision of each.
On Oct 27, 2013, at 6:08 PM, Michael Bayer <[email protected]> wrote: > the indkey column of the pg_index view is an int2vector type (see > http://www.postgresql.org/docs/8.3/static/catalog-pg-index.html), psycopg2 > returns these int2vectors as strings: > > >>> c = psycopg2.connect(user='scott', password='tiger', host='localhost', > >>> database='test') > >>> cursor = c.cursor() > >>> cursor.execute("select indkey from pg_index") > >>> cursor.fetchall() > [('1 2',), ('1 2',), ('1 2',), ('1 2',), ('1 2',), ('1 2',), ('1 2',), …. > > it would appear pypostgresql converts the int2vector into lists. > http://www.sqlalchemy.org/trac/ticket/2855 is added for this. > > For now you’d need to use psycopg2 which runs on Python 3 and is the most > commonly used database adapter for Postgresql. > > > > > > > On Oct 27, 2013, at 4:15 PM, Rich Wellner <[email protected]> wrote: > >> I can reproduce this error in .8 and .9 series. >> >> My SQL creation script: >> >> create table invited_players ( >> invited_player_id integer NOT NULL primary key, >> game_id integer NOT NULL, >> player_id integer NOT NULL >> ); >> >> alter sequence invited_player_id_seq owned by >> invited_players.invited_player_id; >> >> create index invited_play_game_id_idx on invited_players (game_id); >> >> My python: >> >> #!/usr/local/bin/python3 >> >> from sqlalchemy import create_engine >> from sqlalchemy import create_engine, Integer, Column, MetaData, Table, >> Sequence >> from sqlalchemy.orm import mapper, sessionmaker >> >> class InvitedPlayers: >> pass >> >> engine = >> create_engine("postgresql+pypostgresql://username:@localhost:5432/dbname", >> echo=True) >> metadata = MetaData() >> metadata.bind = engine >> >> invitedPlayers = Table("invited_players", metadata, >> Column("invited_player_id", Integer, Sequence('invited_player_id_seq'), >> primary_key=True), >> autoload=True) >> >> The error I receive below occurs when there are two indexes on the table >> (the implicit primary key one and the explicit one I create on game_id). If >> only the primary key index exists then sqlalchemy reflects the table >> properly. Here's the error: >> >> Traceback (most recent call last): >> File "./autoload.py", line 16, in <module> >> autoload=True) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/sql/schema.py", >> line 355, in __new__ >> table._init(name, metadata, *args, **kw) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/sql/schema.py", >> line 428, in _init >> self._autoload(metadata, autoload_with, include_columns) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/sql/schema.py", >> line 456, in _autoload >> self, include_columns, exclude_columns >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/engine/base.py", >> line 1579, in run_callable >> return conn.run_callable(callable_, *args, **kwargs) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/engine/base.py", >> line 1107, in run_callable >> return callable_(self, *args, **kwargs) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/engine/default.py", >> line 296, in reflecttable >> return insp.reflecttable(table, include_columns, exclude_columns) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/engine/reflection.py", >> line 576, in reflecttable >> indexes = self.get_indexes(table_name, schema) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/engine/reflection.py", >> line 383, in get_indexes >> info_cache=self.info_cache, **kw) >> File "<string>", line 1, in <lambda> >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/engine/reflection.py", >> line 53, in cache >> ret = fn(self, con, *args, **kw) >> File >> "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/sqlalchemy/dialects/postgresql/base.py", >> line 2014, in get_indexes >> index['key'] = [int(k.strip()) for k in idx_key.split()] >> AttributeError: 'Array' object has no attribute 'split' >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/sqlalchemy. >> For more options, visit https://groups.google.com/groups/opt_out. > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.
