Hi Michael, after tracing down the issue, I've a fix for it now. The problem was not in reflecttable(). It was in moretableinfo() in mysql.py.
This a diff for mysql.py (not an elegant solution though): 361c361,365 < desc = c.fetchone()[1].strip() --- > desc_fetched = c.fetchone()[1] > if type(desc_fetched) is not str: > # may get array.array object here > desc_fetched = desc_fetched.tostring() > desc = desc_fetched.strip() Here are some explanations: I have been testing on two machines, one running MySQL 4.1.11 and the other MySQL 4.1.14. Python mysql library linked to libmysqlclient_r.so.15 on client machine: # ldd /usr/lib/python2.4/site-packages/_mysql.so linux-gate.so.1 => (0xffffe000) libmysqlclient_r.so.15 => /usr/lib/libmysqlclient_r.so.15 (0xa7e27000) libz.so.1 => /usr/lib/libz.so.1 (0xa7e13000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0xa7e01000) libcrypt.so.1 => /lib/tls/libcrypt.so.1 (0xa7dd3000) libnsl.so.1 => /lib/tls/libnsl.so.1 (0xa7dbc000) libm.so.6 => /lib/tls/libm.so.6 (0xa7d96000) libc.so.6 => /lib/tls/libc.so.6 (0xa7c5e000) /lib/ld-linux.so.2 (0x75555000) After adding 2 lines to moretableinfo() to print c.fetchone()[1] and its type, we have such results for server running MySQL 4.1.14: >>> from sqlalchemy import * >>> engine = create_engine("mysql://...") >>> meta = BoundMetaData(engine) >>> wTable = Table('WMSWarehouses', meta, autoload=True) array('c', "CREATE TABLE `WMSWarehouses` (\n `WarehouseID` int(10) unsigned NOT NULL auto_increment,\n `WarehouseCode` varchar(25) collate utf8_lithuanian_ci NOT NULL default '',\n `WarehouseName` varchar(200) collate utf8_lithuanian_ci NOT NULL default '',\n `WarehouseLocation` text collate utf8_lithuanian_ci,\n `WebServicesURL` varchar(200) collate utf8_lithuanian_ci NOT NULL default '',\n `WarehouseType` enum('CENTRAL','PERIPHERAL') collate utf8_lithuanian_ci NOT NULL default 'CENTRAL',\n `IsIndependentDistr` tinyint(1) NOT NULL default '0',\n `InvoiceSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL default '',\n `PackingListSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL default '',\n `PreliminaryInvoiceSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL default '',\n `ExcDiscount` double(12,2) NOT NULL default '0.00',\n `EcoDiscount` double(12,2) NOT NULL default '0.00',\n `RecomPriceDiscount` double(12,2) NOT NULL default '0.00',\n `OwnerGroup` varchar(100) collate utf8_lithuanian_ci NOT NULL default '',\n `Details` text collate utf8_lithuanian_ci NOT NULL,\n `PresentWarehouseID` int(10) unsigned default NULL,\n PRIMARY KEY (`WarehouseID`),\n UNIQUE KEY `WarehouseCode` (`WarehouseCode`),\n KEY `WarehouseType` (`WarehouseType`),\n KEY `InvoiceSeries` (`InvoiceSeries`),\n KEY `PackingListSeries` (`PackingListSeries`),\n KEY `PreliminaryInvoiceSeries` (`PreliminaryInvoiceSeries`),\n KEY `IsIndependentDistr` (`IsIndependentDistr`),\n KEY `PresentWarehouseID` (`PresentWarehouseID`),\n CONSTRAINT `WMSWarehouses_ibfk_1` FOREIGN KEY (`PresentWarehouseID`) REFERENCES `WMSWarehouses` (`WarehouseID`) ON UPDATE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci") <type 'array.array'> ^ | we have array.array object here instead of str object Results for server running MySQL 4.1.11: >>> from sqlalchemy import * >>> engine = create_engine("mysql://...") >>> meta = BoundMetaData(engine) >>> wTable = Table('WMSWarehouses', meta, autoload=True) CREATE TABLE `WMSWarehouses` ( `WarehouseID` int(10) unsigned NOT NULL auto_increment, `WarehouseCode` varchar(25) collate utf8_lithuanian_ci NOT NULL default '', `WarehouseName` varchar(200) collate utf8_lithuanian_ci NOT NULL default '', `WarehouseLocation` text collate utf8_lithuanian_ci, `WebServicesURL` varchar(200) collate utf8_lithuanian_ci NOT NULL default '', `WarehouseType` enum('CENTRAL','PERIPHERAL') collate utf8_lithuanian_ci NOT NULL default 'CENTRAL', `IsIndependentDistr` tinyint(1) NOT NULL default '0', `InvoiceSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL default '', `PackingListSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL default '', `PreliminaryInvoiceSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL default '', `ExcDiscount` double(12,2) NOT NULL default '0.00', `EcoDiscount` double(12,2) NOT NULL default '0.00', `RecomPriceDiscount` double(12,2) NOT NULL default '0.00', `OwnerGroup` varchar(100) collate utf8_lithuanian_ci NOT NULL default '', `Details` text collate utf8_lithuanian_ci NOT NULL, `PresentWarehouseID` int(10) unsigned default NULL, PRIMARY KEY (`WarehouseID`), UNIQUE KEY `WarehouseCode` (`WarehouseCode`), KEY `WarehouseType` (`WarehouseType`), KEY `InvoiceSeries` (`InvoiceSeries`), KEY `PackingListSeries` (`PackingListSeries`), KEY `PreliminaryInvoiceSeries` (`PreliminaryInvoiceSeries`), KEY `IsIndependentDistr` (`IsIndependentDistr`), KEY `PresentWarehouseID` (`PresentWarehouseID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci <type 'str'> ^ | So the patch seems to be quite obvious. -- Andrius Michael Bayer wrote: > i havent forgotten about this one yet, theres probably some probs with > the regexp in mysql.py that was recently changed to receive foreign key > constraints differently. just need to create this table on this end > and run it. in the meantime, feel free to check out reflecttable() in > mysql.py if you have some resources to spare. > > On Aug 1, 2006, at 1:26 AM, Andrius Armonas wrote: > >> Hi, >> >> here we go with full CREATE statement for the table: >> >> CREATE TABLE `WMSWarehouses` ( >> `WarehouseID` int(10) unsigned NOT NULL auto_increment, >> `WarehouseCode` varchar(25) collate utf8_lithuanian_ci NOT NULL >> default '', >> `WarehouseName` varchar(200) collate utf8_lithuanian_ci NOT NULL >> default '', >> `WarehouseLocation` text collate utf8_lithuanian_ci, >> `WebServicesURL` varchar(200) collate utf8_lithuanian_ci NOT NULL >> default '', >> `WarehouseType` enum('CENTRAL','PERIPHERAL') collate >> utf8_lithuanian_ci NOT NULL default 'CENTRAL', >> `IsIndependentDistr` tinyint(1) NOT NULL default '0', >> `InvoiceSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL >> default '', >> `PackingListSeries` varchar(3) collate utf8_lithuanian_ci NOT NULL >> default '', >> `PreliminaryInvoiceSeries` varchar(3) collate utf8_lithuanian_ci NOT >> NULL default '', >> `ExcDiscount` double(12,2) NOT NULL default '0.00', >> `EcoDiscount` double(12,2) NOT NULL default '0.00', >> `RecomPriceDiscount` double(12,2) NOT NULL default '0.00', >> `OwnerGroup` varchar(100) collate utf8_lithuanian_ci NOT NULL >> default '', >> `Details` text collate utf8_lithuanian_ci NOT NULL, >> `PresentWarehouseID` int(10) unsigned default NULL, >> PRIMARY KEY (`WarehouseID`), >> UNIQUE KEY `WarehouseCode` (`WarehouseCode`), >> KEY `WarehouseType` (`WarehouseType`), >> KEY `InvoiceSeries` (`InvoiceSeries`), >> KEY `PackingListSeries` (`PackingListSeries`), >> KEY `PreliminaryInvoiceSeries` (`PreliminaryInvoiceSeries`), >> KEY `IsIndependentDistr` (`IsIndependentDistr`), >> KEY `PresentWarehouseID` (`PresentWarehouseID`), >> CONSTRAINT `WMSWarehouses_ibfk_1` FOREIGN KEY (`PresentWarehouseID`) >> REFERENCES `WMSWarehouses` (`WarehouseID`) ON UPDATE CASCADE >> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_lithuanian_ci >> >> Thanks, >> -- >> Andrius >> >> >> Michael Bayer wrote: >> >>> need to show us the full CREATE statement for the table,as theres >>> something about it which is not supported; autoloading with MySQL >>> works in the general case. >>> >>> On Jul 31, 2006, at 9:09 AM, Andrius Armonas wrote: >>> >>>> Hi, >>>> >>>> autoload feature doesn't seem to work properly. Calling Table(..., >>>> autoload=True) for the first time raises AttributeError error, and for >>>> the second time - no errors seen. >>>> >>>> What I'm doing is: >>>> >>>> fire:~$ python2.4 >>>> Python 2.4.4c0 (#2, Jun 14 2006, 22:35:41) >>>> [GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-4)] on linux2 >>>> Type "help", "copyright", "credits" or "license" for more information. >>>> >>>>>>> from sqlalchemy import * >>>>>>> engine = create_engine("mysql://...") >>>>>>> meta = BoundMetaData(engine) >>>>>>> wTable = Table('WMSWarehouses', meta, autoload=True) >>>> >>>> Traceback (most recent call last): >>>> File "<stdin>", line 1, in ? >>>> File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 97, in >>>> __call__ >>>> File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line >>>> 488, >>>> in reflecttable >>>> File "build/bdist.linux-i686/egg/sqlalchemy/databases/ mysql.py", >>>> line >>>> 345, in reflecttable >>>> File "build/bdist.linux-i686/egg/sqlalchemy/databases/ mysql.py", >>>> line >>>> 361, in moretableinfo >>>> AttributeError: 'array.array' object has no attribute 'strip' >>>> >>>>>>> wTable = Table('WMSWarehouses', meta, autoload=True) >>>>>>> wTable.name >>>> >>>> 'WMSWarehouses' >>>> >>>> As said, using MySQL 4.1, SA 0.2.6. >>>> >>>> Any help? >>>> >>>> Thanks, >>>> -- >>>> Andrius >>>> >>>> -------------------------------------------------------------------- >>>> ----- >>>> Take Surveys. Earn Cash. Influence the Future of IT >>>> Join SourceForge.net's Techsay panel and you'll get the chance to >>>> share your >>>> opinions on IT & business topics through brief surveys -- and earn >>>> cash >>>> http://www.techsay.com/default.php? >>>> page=join.php&p=sourceforge&CID=DEVDEV >>>> _______________________________________________ >>>> Sqlalchemy-users mailing list >>>> Sqlalchemy-users@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users >> >> ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users