p3:pyCharm与mysql

栏目: Python · 发布时间: 8年前

内容简介:p3:pyCharm与mysql

1、安装mysql

debian执行: sudo apt-get install mysql-server  mysql-client

2、安装 pythonmysql 接口

接口or驱动 非常多,主流的有pymysql、mysql-connector等等,这里推荐pymysql

执行:pip3 install pymysql

3、连接

1 import pymysql
2 
3 # 创建连接
4 conn = pymysql.connect(host='localhost', port=3306, charset='utf8',
5                        user='username', password='123789', database='test1db')
6 cr = conn.cursor(  # 创建游标,默认获取的数据是元祖类型
7     cursor=pymysql.cursors.DictCursor)  # 游标设为字典类型
8 print(conn)
9 db = cr.execute("show databases")  # 返回受影响行数

4、pyCharm简单管理

p3:pyCharm与mysql

执行1、2、3,进入设置窗口

p3:pyCharm与mysql

配置后点OK,

p3:pyCharm与mysql

点击数据连接名后面的3个点(...),选schemas按F4键(Open Console)。应该就能看到所连的库了。

可以直观的看到图形管理界面:

p3:pyCharm与mysql

p3:pyCharm与mysql


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Essential PHP Security

Essential PHP Security

Chris Shiflett / O'Reilly Media / 2005-10-13 / USD 29.95

Being highly flexible in building dynamic, database-driven web applications makes the PHP programming language one of the most popular web development tools in use today. It also works beautifully wit......一起来看看 《Essential PHP Security》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具