Re: How to connect Python3.4.1 to Mysql 5.1 ?

2014-06-27 Thread jaahush

I am sure you could google this
but here's what I've done in the past


1) file 1 has the login info.
   I make it to prompt for user's password
   (you could hardcode the password in this file)

import getpass

USERNAME = "yourusername"
DBNAME   = "yourdatabasename"
PASSWORD = getpass.getpass("Enter password for database {0}: ".format(DBNAME))

login_info = {
   'host' : "your.sql.server.domain.name",
   'user' : USERNAME,
   'password' : PASSWORD,
   'database' : DBNAME,
   'port' : yoursqlport,
 }

2) file 2 has the SQL code

import mysql.connector
from file_1_above import login_info

db = mysql.connector.Connect(**login_info)
cursor = db.cursor()


>From here on, you use "cursor" to operate on your database.


-- 
https://mail.python.org/mailman/listinfo/python-list


How to connect Python3.4.1 to Mysql 5.1 ?

2014-06-25 Thread Raja Sekhar
Can any body tell how to access data from mysql using python. I am using python 
version 3.4.1 and Mysql version 5.1
-- 
https://mail.python.org/mailman/listinfo/python-list