http://askubuntu.com/questions/630728/how-to-access-mysql-with-python-version-3-4

Python comes in two versions: Python 2.7.6 which has now been superseded by Python 3.4.0. The critical line in Python to access MySQL is "import MySQLdb"

Thanks to a response from StackOverFlow, I realized that I was unintentionally accessing MySQL through Python version 2.7.6. Apparently, "MySQLdb" is not compatible with Python version 3.4.0.

Searching the internet has disclosed alternatives for connecting Python to MySql, however, many of the suggestions do not disclose whether the offered solutions would actually work with Python version 3.4.0.

This StackOverFlow Post listed some possible solutions. Python 3.4.0 with MySQL database. I installed mysqlclient 1.3.6, I also ran "sudo pip install PyMySQL" with out error.

However, upon entering python with "python3"; I still received the error message "ImportError: No module named 'MySQLdb'" after typing in: "import MySQLdb". So something was still wrong.

As an FYI MySQL evidently has its own connector, but I don't know whether it works or does not work with Python 3.4. Connecting to MySQL Using Connector/Python I will have to look into this more.

Any advice on how to connect Python 3.4 with MySQL?

asked Jun 1 '15 at 0:36
Steve R.

71214
 

The documentation for MySQL Connector/Python says Version 2.0 should work with MySQL Server 5.5-5.7 and Python 3.3 and later. So I would say it's a good bet. If it doesn't work, follow up with what error you encounter and I'll see if I can help.

answered Jun 1 '15 at 5:10
Synergist

24718
 
    
Thanks. Will give it a try. – Steve R. Jun 1 '15 at 17:27
    
Let me know if it works please. – Synergist Jun 1 '15 at 17:43
    
Sort of. When I type in just plain python then " import mysql.connector" it works. When I type in python3then " import mysql.connector" it fails with the message "ImportError: No module named 'mysql'". Implies a configuration issue (such as path) with Python 3.4.0? – Steve R. Jun 1 '15 at 18:04
    
How did you install MySQL Connector? – Synergist Jun 1 '15 at 18:09
    
Turns out that the new version is available through the Ubuntu Software Center. However, I had to remove the old "python-mysql.connector" (version 1.1.6-1) before I could install the new version of the python connector. I only ran the install from the Ubuntu Software Center. Did not underake any other configuration. – Steve R.Jun 1 '15 at 18:20

How to Access MySQL with Python Version 3.4的更多相关文章

  1. linux查看是否安装Apache,mysql,python等

    1.Apache httpd -v service httpd start 启动 service httpd restart 重新启动 service httpd stop 停止服务 2.mysql ...

  2. mysql及python交互

    mysql在之前写过一次,那时是我刚刚进入博客,今天介绍一下mysql的python交互,当然前面会把mysql基本概述一下. 目录: 一.命令脚本(mysql) 1.基本命令 2.数据库操作命令 3 ...

  3. 安装 pywin32-218.win32-py2.7.exe 报错python version 2.7 required,which was not found in the registry解决方案

    随便在一个盘下 新建register.py的文件,内容如下: #   # script to register Python 2.0 or later for use with win32all    ...

  4. 【转】安装第三方库出现 Python version 2.7 required, which was not found in the registry

    安装第三方库出现 Python version 2.7 required, which was not found in the registry 建立一个文件 register.py 内容如下. 然 ...

  5. Python 安装Twisted 提示python version 2.7 required,which was not found in the registry

    由于我安装Python64位的,下载后没注册,安装Twisted时老提示“python version 2.7 required,which was not found in the registry ...

  6. 在Ubuntu上安装Mysql For Python

    安装: 首先安装pip,并且把pip更新到最小版本 apt-get install python-pip pip install -U pip 安装mysql开发包 apt-get install p ...

  7. 未能加载文件或程序集“MySql.Web.v20, Version=6.9.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d”或它的某一个依赖项。系统找不到指定的文件

    未能加载文件或程序集“MySql.Web.v20, Version=6.9.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d”或它的某一个依赖 ...

  8. Snippet: Fetching results after calling stored procedures using MySQL Connector/Python

    https://geert.vanderkelen.org/2014/results-after-procedure-call/ Problem Using MySQL Connector/Pytho ...

  9. 安装第三方库出现 Python version 2.7 required, which was not found in the registry

    安装第三方库出现 Python version 2.7 required, which was not found in the registry 建立一个文件 register.py 内容如下. 然 ...

随机推荐

  1. ASP.NET 如何判断当前请求是否是Ajax请求

    /// <summary>        /// Description:验证用户是否登陆        /// Author:xucixiao        /// Date:2013- ...

  2. IDE:Eclipse查看接口实现类快捷键

    1.打开接口类 2.双击接口名选中 3.Ctrl+T,打开接口实现类

  3. 找到SQL Server的序列号

          有时候希望获取当前机器上安装的SQL Server序列号,但注册表中序列号是经过加密的,因此我写了一个小工具获取当前SQL Server的序列号.程序比较粗糙,没有做错误验证.       ...

  4. WCF传输1-你是否使用过压缩或Json序列化?

    1.当遇到需要传输大量数据时,怎么样传输数据? 2.压缩数据有哪几种常见的方式? 问题1解答:通过压缩来传输数据 问题2解答: (1)WCF自带的压缩方式 (2)自定义WCF binding进行压缩 ...

  5. 【博客美化】08.添加"扩大/缩小浏览区域大小" 按钮

    博客园美化相关文章目录: [博客美化]01.推荐和反对炫酷样式 [博客美化]02.公告栏显示个性化时间 [博客美化]03.分享按钮 [博客美化]04.自定义地址栏logo [博客美化]05.添加Git ...

  6. java中有关线程的题目

    1,看一下下面程序错误发生在哪一行! class Test implements Runnable{ public void run(Thread t){ } } 2,输出结果是什么? class T ...

  7. Mina、Netty、Twisted一起学(十):线程模型

    要想开发一个高性能的TCP服务器,熟悉所使用框架的线程模型非常重要.MINA.Netty.Twisted本身都是高性能的网络框架,如果再搭配上高效率的代码,才能实现一个高大上的服务器.但是如果不了解它 ...

  8. 《Administrator's Guide》之Managing Memory

    Automatic Memory Management 1. 如果要启动Automatic Memory Management,如何确定MEMORY_TARGET的值呢? 1> 在SQL*Plu ...

  9. (转)清理AIX的/var文件系统大小

    在ROOTVG空间有限,且/var文件系统的空间已经足够大的情况下,/var文件系统空间快满了,这种情况怎么处理?IBM给了一个很好的处理流程: 使用find 命令检查在/var目录中所有大于1MB的 ...

  10. Java多线程系列--“JUC原子类”05之 AtomicLongFieldUpdater原子类

    概要 AtomicIntegerFieldUpdater, AtomicLongFieldUpdater和AtomicReferenceFieldUpdater这3个修改类的成员的原子类型的原理和用法 ...