当前位置:Gxlcms > 数据库问题 > Python—>Mysql—>Dbvisualizer

Python—>Mysql—>Dbvisualizer

时间:2021-07-01 10:21:17 帮助过:3人阅读

-*- coding: utf8 -*- import mysql.connector conn=mysql.connector.connect( host=127.0.0.1, port=3306, user=root, passwd=1qaz@WSX, db=test, ) cursor = conn.cursor() cursor.execute ("SELECT VERSION()") row = cursor.fetchone () print "server version:", row[0] cursor.close() conn.close()

 

 

4.管理数据库

DbVisualizer 8.0.8管理

CREATE TABLE 表名 (字段名 VARCHAR(20), 字段名 CHAR(1));

create table pet(

name varchar(20), #名字

owner varchar(20),#主人

species varchar(20), #种类       

sex char(1),  #性别      

birth date, #出生日期       

death date,#死亡日期)

 

show tables;

select * from tb;

 

要建立外键关系,首先要保证用来建立外键关系的列具有唯一性,即具有 UNIQUE 约束

通常是某表的主键作为另外一个表的外键

 

mysql版本和驱动版本不匹配

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 an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘)‘ at 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 an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘)‘ at 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

 

下载更新驱动:

mysql-connector-java-5.1.38.zip

最后更新到dbvis jar包到相应的目录下就行

技术分享

DbVisualizer-8.0.8\jdbc\mysql

失败原因:

技术分享

 

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

 

Msql终端添加:

alter table student add constraint score_student_fk1 foreign key (ScoreID)  references score(ScoreID)

alter table student add constraint score_student_fk1 foreign key (ScoreID) references score(ScoreID)

Python—>Mysql—>Dbvisualizer

标签:

人气教程排行