Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

MYSQL Python sqlalchemy (no replies)

$
0
0
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?

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>