Skip navigation links

MySQL Forums :: Connector/Python :: MYSQL Python sqlalchemy


Advanced Search

MYSQL Python sqlalchemy
Posted by: Sam Koekemoer ()
Date: February 18, 2011 06:23AM

I need to create wordpress databases using mysqldb connected to a mysql server but using the SQLAlchemy code. The SQL for the table is as follows:
CREATE TABLE IF NOT EXISTS `wp_links` (
`link_id` bigint(20) unsigned NOT NULL auto_increment,
`link_url` varchar(255) NOT NULL default '',
`link_name` varchar(255) NOT NULL default '',
`link_image` varchar(255) NOT NULL default '',
`link_target` varchar(25) NOT NULL default '',
`link_description` varchar(255) NOT NULL default '',
`link_visible` varchar(20) NOT NULL default 'Y',
`link_owner` bigint(20) unsigned NOT NULL default '1',
`link_rating` int(11) NOT NULL default '0',
`link_updated` datetime NOT NULL default '0000-00-00 00:00:00',
`link_rel` varchar(255) NOT NULL default '',
`link_notes` mediumtext NOT NULL,
`link_rss` varchar(255) NOT NULL default '',
PRIMARY KEY (`link_id`),
KEY `link_visible` (`link_visible`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;

This is the python code that I wrote to do the same thing:
wp_links = []#links table
wp_links.append (Table ('wp_links', metadata, Column ('link_id', BIGINT(20, unsigned=True),nullable=False, primary_key=True),
Column('link_url', VARCHAR(255), nullable=False, server_default=''),
Column('link_name', VARCHAR(255), nullable=False, server_default=''),
Column('link_image', VARCHAR(255), nullable=False, server_default=''),
Column('link_target', VARCHAR(255), nullable=False, server_default=''),
Column('link_description', VARCHAR(255), nullable=False, server_default=''),
Column('link_visible', VARCHAR(20), key='link_visible', nullable=False, server_default='Y'),
Column('link_owner', BIGINT(20, unsigned=True), nullable=False, server_default='1'),
Column('link_rating', INTEGER(11), nullable=False, server_default='0'),
Column('link_updated', DATETIME(), nullable=False, server_default='0000-00-00 00:00:00'),
Column('link_rel', VARCHAR(255), nullable=False, server_default=''),
Column('link_notes', MEDIUMTEXT(), nullable=False),
Column('link_rss', VARCHAR(255), nullable=False, server_default='')))

Which translates to the following SQL:
CREATE TABLE IF NOT EXISTS `wp_links` (
`link_id` bigint(20) unsigned NOT NULL auto_increment,
`link_url` varchar(255) NOT NULL default '',
`link_name` varchar(255) NOT NULL default '',
`link_image` varchar(255) NOT NULL default '',
`link_target` varchar(255) NOT NULL default '',
`link_description` varchar(255) NOT NULL default '',
`link_visible` varchar(20) NOT NULL default 'Y',
`link_owner` bigint(20) unsigned NOT NULL default '1',
`link_rating` int(11) NOT NULL default '0',
`link_updated` datetime NOT NULL default '0000-00-00 00:00:00',
`link_rel` varchar(255) NOT NULL default '',
`link_notes` mediumtext NOT NULL,
`link_rss` varchar(255) NOT NULL default '',
PRIMARY KEY (`link_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Note the difference, the line “KEY `link_visible` (`link_visible`)” is not present. How do I correct my Python code to make them identical?

Options: ReplyQuote


Subject Written By Posted
MYSQL Python sqlalchemy Sam Koekemoer 02/18/2011 06:23AM
Re: MYSQL Python sqlalchemy Geert Vanderkelen 03/16/2011 03:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.