Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > python and MySQL - 3 questions

Reply
Thread Tools

python and MySQL - 3 questions

 
 
el chupacabra
Guest
Posts: n/a
 
      10-10-2005
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/ =-

 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      10-10-2005

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

On Mon, 10 Oct 2005 05:03:40 GMT, "el chupacabra" <(E-Mail Removed)>
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.
--
> ================================================== ============ <
> http://www.velocityreviews.com/forums/(E-Mail Removed) | Wulfraed Dennis Lee Bieber KD6MOG <
> (E-Mail Removed) | Bestiaria Support Staff <
> ================================================== ============ <
> Home Page: <http://www.dm.net/~wulfraed/> <
> Overflow Page: <http://wlfraed.home.netcom.com/> <

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python and Connecting to MySQL remotely WITHOUT MySQL installedon local computer dave Python 4 11-18-2010 04:19 AM
Re: How to insert PDF file in to MySql and read it from MySql toJAVA App Jeffrey H. Coffield Java 1 07-24-2009 12:29 AM
MySQL-python-1.2.2 install with no mysql washakie Python 4 01-15-2008 08:15 PM
"mysql.h: No such file or directory" when building MySQL-python francescomoi@europe.com Python 2 05-11-2005 03:12 PM
"Pure Python" MySQL module like Net::MySQL Ravi Python 6 07-21-2003 06:53 PM



Advertisments