Python->mysql->dbvisualizer

Source: Internet
Author: User
Tags mysql version python mysql dbvisualizer

1.Download Connector/python:mysql-connector-python-2.1.3-py2.7-win32

mysql:mysql-installer-community-5.5.48.0

python:python-2.7.10

2. Install the Python,mysql

Connector/python:http://dev.mysql.com/doc/connector-python/en/connector-python-installation.html

Python3 no longer supports MYSQLDB,

Replaced by: Import pymysql Python MySQL Official pack: Mysql-connector-python

3. Test code

Mysql: View all users select * from Mysql.user;

show databases; ----------View all databases

Use test; --Using the database

#-*-Coding:utf8-*-ImportMysql.connectorconn=Mysql.connector.connect (Host='127.0.0.1', Port=3306, the user='Root', passwd='[email protected]', DB='Test',) cursor=conn.cursor () cursor.execute ("SELECT VERSION ()") Row=Cursor.fetchone ()Print "Server version:", Row[0] Cursor.close () conn.close ()

4. Managing Databases

Dbvisualizer 8.0.8 Management

CREATE Table table name (field name VARCHAR (20), Field name CHAR (1));

CREATE TABLE Pet (

Name varchar, #名字

Owner varchar, #主人

Species varchar (+), #种类

Sex char (1), #性别

Birth date, #出生日期

Death date, #死亡日期)

Show tables;

SELECT * from TB;

To establish a foreign key relationship, first ensure that the column used to establish the foreign key relationship is unique, that is, with a unique constraint

is usually a table's primary key as a foreign key to another table

MySQL version and driver version do not match

An error occurred while executing the database request for:
Mysql
5.5.47-log
Mysql-ab JDBC Driver
mysql-connector-java-5.1.16 (Revision: ${bzr.revision-id})

Short message:
An error occurred while performing the operation:
You have a error in your SQL syntax; Check the manual, corresponds to your MySQL server version for the right syntax to use near ') ' on line 1

The command that caused the problem:
ALTER TABLE testdjango.student ADD CONSTRAINT student_fk1 FOREIGN KEY (Scoreid) REFERENCES Testdjango.pet ()

Long Message:
You have a error in your SQL syntax; Check the manual, corresponds to your MySQL server version for the right syntax to use near ') ' on line 1

Details:
Type:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
Error code:1064
SQL state:42000

System Information:
Product:dbvisualizer Personal 8.0.8
Build: #1745 (2012/02/14 10:52)
Java Vm:java HotSpot (TM) Client VM
Java version:1.6.0_20
Java Vendor:sun Microsystems Inc.
OS Name:windows 7
OS arch:x86
OS version:6.1

Download Update Driver:

Mysql-connector-java-5.1.38.zip

Finally, update to the Dbvis jar package to the appropriate directory.

Dbvisualizer-8.0.8\jdbc\mysql

Reason for failure:

Http://www.cnblogs.com/edisonfeng/archive/2014/06/05/3766243.html

mSQL Terminal add:

ALTER TABLE student ADD constraint SCORE_STUDENT_FK1 foreign key (Scoreid) references score (Scoreid)

Alter Table Add constraint Foreign Key references score (Scoreid)

Python->mysql->dbvisualizer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.