[sqlalchemy] reflection failure with MySQL: Mapper could not assemble any primary key columns for mapped table
Hey, I'm trying to use reflection with SQLAlchemy 0.8 but I always get this exception: sqlalchemy.exc.ArgumentError: Mapper Mapper|links|links could not assemble any primary key columns for mapped table 'links' mysql show fields from links; ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-+---+ | l_from | int(8) unsigned | NO | PRI | 0 | | | l_to | int(8) unsigned | NO | PRI | 0 | | ++-+--+-+-+---+ 2 rows in set (0.00 sec) The class definition is pretty simple: class links(Base): __table__ = Table('links', Base.metadata, autoload=True) Traceback: File …/main.py, line 36, in connect_to_db class links(Base): File …/sqlalchemy/ext/declarative.py, line 1343, in __init__ _as_declarative(cls, classname, cls.__dict__) File …/sqlalchemy/ext/declarative.py, line 1336, in _as_declarative **mapper_args) File …/sqlalchemy/orm/__init__.py, line 1129, in mapper return Mapper(class_, local_table, *args, **params) File …/sqlalchemy/orm/mapper.py, line 203, in __init__ self._configure_pks() File …/sqlalchemy/orm/mapper.py, line 773, in _configure_pks (self, self.mapped_table.description)) Any idea why this happens and how I fix the problem? (without having to specify the ORM mapping myself) fs -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] reflection failure with MySQL: Mapper could not assemble any primary key columns for mapped table
can you send the SHOW CREATE TABLE, I'll copy it exactly On Mar 11, 2013, at 9:59 AM, Felix Schwarz felix.schw...@oss.schwarz.eu wrote: Hey, I'm trying to use reflection with SQLAlchemy 0.8 but I always get this exception: sqlalchemy.exc.ArgumentError: Mapper Mapper|links|links could not assemble any primary key columns for mapped table 'links' mysql show fields from links; ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-+---+ | l_from | int(8) unsigned | NO | PRI | 0 | | | l_to | int(8) unsigned | NO | PRI | 0 | | ++-+--+-+-+---+ 2 rows in set (0.00 sec) The class definition is pretty simple: class links(Base): __table__ = Table('links', Base.metadata, autoload=True) Traceback: File …/main.py, line 36, in connect_to_db class links(Base): File …/sqlalchemy/ext/declarative.py, line 1343, in __init__ _as_declarative(cls, classname, cls.__dict__) File …/sqlalchemy/ext/declarative.py, line 1336, in _as_declarative **mapper_args) File …/sqlalchemy/orm/__init__.py, line 1129, in mapper return Mapper(class_, local_table, *args, **params) File …/sqlalchemy/orm/mapper.py, line 203, in __init__ self._configure_pks() File …/sqlalchemy/orm/mapper.py, line 773, in _configure_pks (self, self.mapped_table.description)) Any idea why this happens and how I fix the problem? (without having to specify the ORM mapping myself) fs -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] Re: reflection failure with MySQL: Mapper could not assemble any primary key columns for mapped table
can you send the SHOW CREATE TABLE, I'll copy it exactly CREATE TABLE `links` ( `l_from` int(8) unsigned NOT NULL DEFAULT '0', `l_to` int(8) unsigned NOT NULL DEFAULT '0', UNIQUE KEY `l_from` (`l_from`,`l_to`), KEY `l_to` (`l_to`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 (sorry for breaking the threading, due to some misconfiguration I saw Michael's mail only in the web interface.) -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] reflection failure with MySQL: Mapper could not assemble any primary key columns for mapped table
OK well that table has no primary key established. If I create a table with a PK: create table test (id integer primary key); you see PRIMARY KEY in the output: mysql show create table test; +---+--+ | Table | Create Table | +---+--+ | test | CREATE TABLE `test` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 | +---+--+ 1 row in set (0.00 sec) so in this case you'd need to specify PK cols in your Table or in your mapper def. On Mar 11, 2013, at 11:14 AM, Felix Schwarz felix.schw...@oss.schwarz.eu wrote: can you send the SHOW CREATE TABLE, I'll copy it exactly CREATE TABLE `links` ( `l_from` int(8) unsigned NOT NULL DEFAULT '0', `l_to` int(8) unsigned NOT NULL DEFAULT '0', UNIQUE KEY `l_from` (`l_from`,`l_to`), KEY `l_to` (`l_to`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 (sorry for breaking the threading, due to some misconfiguration I saw Michael's mail only in the web interface.) -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] Re: SQLAlchemy 0.8.0 Released
Hey Mike, Thanks the fantastic work you have been offering to the open source community over the years ! I am personally very grateful and I am sure a lot of people think the same. Maybe should you jump directly to version SQLA 1.1 as people think 1.0 versions are still immature and they would rather wait and let others stumble on bugs first -- you know, it's the first stable version after all. ;) Cheers, 2013/3/9 Michael Bayer mike...@zzzcomputing.com Hey gang - After a long delay I've finally put out 0.8.0 final.Work on 0.8.0 began almost a year ago, and since then the release has shaped up very nicely, including that we've had a very long beta period. Due to the behavior of pip, lots of you have already been using 0.8.0b2 as pip doesn't honor the hidden flag on Pypi. For those on 0.7, upgrading to 0.8 shouldn't be very hard, though obviously it should be tested fully, as there are some behavioral changes. For a list of every known behavioral change, please refer to the Behavioral Changes section of the migration document at http://docs.sqlalchemy.org/en/rel_0_8/changelog/migration_08.html . For those who have been on 0.8.0b2, there are three very small additional behavioral changes that I doubt the vast majority of users will notice; they are also noted at the top of the changelog. Overall I think the impression you'll get from the changes is that we're really in the long tail of refinement at this point. Whereas most previous major releases I've spent lots of time refactoring for performance, in this release I've gone back to refactoring for more correctness and clarity (albeit often very intricate clarity, necessarily) within many areas of the code, particularly the ORM.Whereas before, I'd focus on inlining and reducing method calls, at this stage I've been able to start breaking up some of the more monolithic sections back into small modular and more testable bits without any real impact on performance. The mechanics of relationships as well as polymorphic querying have seen major changes, and I'm sort of blown away at the level of queries this thing can pull out in those areas (though there's *still* lots more things we need to do with querying). We've moved to support Python 2.5 at the lowest (and we will very quickly be moving that up to 2.6), rewritten a *lot* of tests (though we're over 5000 now, so there's plenty more tests that need to be pulled into the modern age), and planted the seeds for a growing ecosystem of external third party dialects, including those of SQLAlchemy's new friends, IBM (were we've helped them to modernize and release an all-new DB2 dialect) and Akiban (a great new database company in Boston). The blog post at http://www.sqlalchemy.org/blog/#sqlalchemy-0.8.0-releasedgives a top-level sales pitch for 0.8.0 as well as a rundown of some of the biggest changes. I will note that I am trying to push SQLAlchemy towards a 1.0 status as fast as possible at this point; there is a roadmap for 0.9, but I may decide to first skip to 1.0 soon within the 0.8 series (basically it would be an 0.8.x renamed as 1.0), then 0.9 would become 1.1 (if that makes sense). It's only a few days before Pycon, where I'll be doing an Introduction to SQLAlchemy tutorial as well as a repeat of my Session in Depth talk, and am looking forward to seeing the whole gang this year. I'd like to thank everyone who has helped with this release, starting with code contributions that began at last year's Pycon. And a *huge* thanks to those folks tipping me on Gittip and Flattr, and the handful of professional clients who have contributed towards the codebase this year, as well as those folks chipping in on the mailing list and on StackOverflow. I'd recommend everyone get onto Gittip (it's free to join of course!), on some of those Mondays where I see a new user has already been helped on the mailing list, allowing me to get on with my day, I'd love to send a few bytes over to those helpful folks in return. SQLAlchemy 0.8.0 can be downloaded at: http://www.sqlalchemy.org/download.html Full changelog: http://www.sqlalchemy.org/changelog/CHANGES_0_8_0 -- You received this message because you are subscribed to the Google Groups sqlalchemy-devel group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-devel+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy-de...@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- Alex -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at
[sqlalchemy] Inserting Entry Fastest way
Hi, I am working on a database design that I am required to use lots of tables with one-to-many relationship. As a consequence of the design, I need to insert thousands of entries. I tried session.add(), session.merge, however none of them is fast enough for me to meet the requirements. I was wondering if you can suggest me an efficient way through either ORM or ORM+Core. Thanks! -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] Re: Inserting Entry Fastest way
On Monday, March 11, 2013 4:56:11 PM UTC-4, Arkilic, Arman wrote: Hi, I am working on a database design that I am required to use lots of tables with one-to-many relationship. As a consequence of the design, I need to insert thousands of entries. I tried session.add(), session.merge, however none of them is fast enough for me to meet the requirements. I was wondering if you can suggest me an efficient way through either ORM or ORM+Core. Thanks! I recently did a presentation structured around getting fast bulk inserts with SQLAlchemy. You may find it useful: https://speakerdeck.com/rwarren/a-brief-intro-to-profiling-in-python Please note that the focus was on profiling, and not on SQLAlchemy. The SQLAlchemy example just worked out well (with a contrived step or two) as a vehicle for showing different profiling steps/gotchas. Since the focus was on profiling, the example is quite simple (a single user table)... but you can easily extend on it for your one-to-many tables. I also didn't 100% scrub the SQLAlchemy code (I threw this together in a hurry), so no yelling at me for bad code. :) Russ -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] Inserting Entry Fastest way
I wrote a detailed description of what's going on regarding INSERT here: http://stackoverflow.com/questions/11769366/why-is-sqlalchemy-insert-with-sqlite-25-times-slower-than-using-sqlite3-directly/11769768#11769768 On Mar 11, 2013, at 4:56 PM, Arkilic, Arman arki...@bnl.gov wrote: Hi, I am working on a database design that I am required to use lots of tables with one-to-many relationship. As a consequence of the design, I need to insert thousands of entries. I tried session.add(), session.merge, however none of them is fast enough for me to meet the requirements. I was wondering if you can suggest me an efficient way through either ORM or ORM+Core. Thanks! -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[sqlalchemy] Should an empty HSTORE be returned as an empty dict?
Hi, Currently, when getting an empty HSTORE column from a model instance, it is returned as None. Do you think it would be more logical to have it returned as an empty dict? Thanks, Charles -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] Re: Inserting Entry Fastest way
Thanks Russ - took a look and found it very interesting indeed. Cheers Warwick On Monday, March 11, 2013 4:56:11 PM UTC-4, Arkilic, Arman wrote: Hi, I am working on a database design that I am required to use lots of tables with one-to-many relationship. As a consequence of the design, I need to insert thousands of entries. I tried session.add(), session.merge, however none of them is fast enough for me to meet the requirements. I was wondering if you can suggest me an efficient way through either ORM or ORM+Core. Thanks! I recently did a presentation structured around getting fast bulk inserts with SQLAlchemy. You may find it useful: https://speakerdeck.com/rwarren/a-brief-intro-to-profiling-in-python Please note that the focus was on profiling, and not on SQLAlchemy. The SQLAlchemy example just worked out well (with a contrived step or two) as a vehicle for showing different profiling steps/gotchas. Since the focus was on profiling, the example is quite simple (a single user table)... but you can easily extend on it for your one-to-many tables. I also didn't 100% scrub the SQLAlchemy code (I threw this together in a hurry), so no yelling at me for bad code. :) Russ -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] Inserting Entry Fastest way
On Mar 11, 2013, at 5:19 PM, Russ russandheat...@gmail.com wrote: On Monday, March 11, 2013 4:56:11 PM UTC-4, Arkilic, Arman wrote: Hi, I am working on a database design that I am required to use lots of tables with one-to-many relationship. As a consequence of the design, I need to insert thousands of entries. I tried session.add(), session.merge, however none of them is fast enough for me to meet the requirements. I was wondering if you can suggest me an efficient way through either ORM or ORM+Core. Thanks! I recently did a presentation structured around getting fast bulk inserts with SQLAlchemy. You may find it useful: https://speakerdeck.com/rwarren/a-brief-intro-to-profiling-in-python Please note that the focus was on profiling, and not on SQLAlchemy. The SQLAlchemy example just worked out well (with a contrived step or two) as a vehicle for showing different profiling steps/gotchas. Since the focus was on profiling, the example is quite simple (a single user table)... but you can easily extend on it for your one-to-many tables. I also didn't 100% scrub the SQLAlchemy code (I threw this together in a hurry), so no yelling at me for bad code. :) wow that is a great talk, I laughed my ass off and you really got in there, nice job ! Russ -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [sqlalchemy] Inserting Entry Fastest way
wow that is a great talk, I laughed my ass off and you really got in there, nice job ! Thanks! As long as you weren't laughing because I did the sqlalchemy all wrong! :) Russ -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.