473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

python and MySQL - 3 questions

I'm using mysqldb module and python 2.4. I'm a newbie. Thanks in advance.

1. Output desired:

"hello"
"world"

I know that MySQL takes \n and \t and what not.

But my python script, it takes that \n as literal. Meaning, when I retrieve the records, they show up like "hello \n world".

How can keep formatting when inserting data to table?

This is what I have:

cursor.execute('insert into table values (%s, %s, %s, %s)', (newId, insertEntryName, insertLastName, insertSSN)
2. How can make my python show *** (stars) when entering user passwords?

3. Is it possible to make Python/MySQL transactions secure, encrypted? Can you point me to readings or something?

--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-

Oct 10 '05 #1
1 2004

<<< cue theme from "The Prisoner" >>>
"Information.... We want... Information..."

On Mon, 10 Oct 2005 05:03:40 GMT, "el chupacabra" <no*******@noway.com>
declaimed the following in comp.lang.python:
I'm using mysqldb module and python 2.4. I'm a newbie. Thanks in advance.

1. Output desired:

"hello"
"world"

I know that MySQL takes \n and \t and what not.
Show us the exact input...

print repr(instuff)

Then show us the exact output...

print repr(outstuff)
import MySQLdb
cn = MySQLdb.Connect(host="localhost", db="test", user="test")
cr = cn.cursor()
instuff = "Dennis\tLee\nBieber"
cr.execute("insert into junk (aString) values (%s)", instuff) 1L cn.commit()
cr.execute("select ID, aString from junk") 1L (id, outstuff) = cr.fetchone()
print repr(instuff) 'Dennis\tLee\nBieber' print repr(outstuff) 'Dennis\tLee\nBieber'
print instuff Dennis Lee
Bieber print outstuff Dennis Lee
Bieber


Sure look the same to me...


2. How can make my python show *** (stars) when entering user passwords?

Command line console, Tkinter, Win32 native, wxPython, GTK? They all
have different ways...

However, as a start... open the Python help system and look for
password... You should find:

"""
6.13 getpass -- Portable password input

The getpass module provides two functions:

getpass( [prompt])
Prompt the user for a password without echoing. The user is prompted
using the string prompt, which defaults to 'Password: '. Availability:
Macintosh, Unix, Windows.

getuser( )
Return the ``login name'' of the user. Availability: Unix, Windows.
This function checks the environment variables LOGNAME, USER, LNAME and
USERNAME, in order, and returns the value of the first one which is set
to a non-empty string. If none are set, the login name from the password
database is returned on systems which support the pwd module, otherwise,
an exception is raised.
"""
3. Is it possible to make Python/MySQL transactions secure, encrypted? Can you point me to readings or something?

SSH?

The MySQL reference manual?

Page 141/142 of the Black/Brown MySQL/O'Reilly manual has a chapter
on using SSH on Windows for a secure connection.

I'd expect the newer MySQL press manuals have the same chapter.
-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Oct 10 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael Foord | last post by:
I'm writing a couple of modules that store information about user 'behaviour'. E.g. a user accesses a certain page of a website at a certain date-time with a certain referrer. I need to analyse...
14
by: Sam | last post by:
Hi, I have been developing sites and cms's for the past few years using PHP and mysql. I've been interested in learning a new language and was considering Python. I have a pretty decent grasp of...
4
by: hot.favorite | last post by:
Hi, I'm fairly new to Python so please pardon any dumbness on my part. I plan to write an app in Python that will run on Linux and would need to connect to Oracle and MySQL. I could use...
2
by: Richard Brosnahan | last post by:
I hate asking questions that have probably been answered before, but I have not found a way to conveniently search the archives of this mailing list. So... Can someone tell me how to...
48
by: northband | last post by:
Hi, I am interested in re-writing my website in Python vs PHP but have a few questions. Here are my specs, please advise as to which configuration would be best: 1.Dell Poweredge Server, w/IIS,...
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
13
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
34
by: Anthony Irwin | last post by:
Hi All, I am currently trying to decide between using python or java and have a few quick questions about python that you may be able to help with. #1 Does python have something like javas...
27
by: gerrymcc | last post by:
Hello, I'm a php/mysql beginner... Is there any way of making the mysql command line client full-screen? Sometimes it's easier to use the client than go thru php, but since it's only about 80...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.