Re: MySQLdb + SSH Tunnel
Got it working. Thanks for your help 1) login to B 2) setup a tunnel in the shell machine-B> ssh -L B_ip_address:B_port:C_ip_address:C_port u...@c_ip_address for example: machine-B has ip 1.1.1.1 machine-C has ip 2.2.2.2 then I would type: machine-B> ssh -L 1.1.1.1:3307:2.2.2.2:3306 u...@2.2.2.2 now the code that is running on machine-A would use MySQLdb in the following way import MySQLdb connection = MySQLdb.connect (user='myname',passwd='mypass',db='mydb',host='1.1.1.1',port=3307) NOTE: the port is an integer, NOT a string On Jul 12, 9:18 pm, Riley Crane wrote: > OVERVIEW: > I am running a script on one machine that connects to a MySQL database > on another machine that is outside of our university's domain. > According to the administrator, network policies do not allow the > compute nodes to access machines outside of our university's domain. > > COMPUTERS: > A = compute node within university (I do not have shell access) > B = 2nd machine within university that does not block outside > connections (I have root access) > C = machine outside of university (I have root access) > mysqldb on A cannot connect to C but. > mysqldb on A can connect to B > > WHAT I WOULD LIKE TO DO: > Is it possible to set something up where A talks to a port on B, and > that port is actually nothing more than 3306 on C? Can I do this with > an SSH tunnel? > > Can anyone please give precise instructions? -- http://mail.python.org/mailman/listinfo/python-list
Re: database in python ?
On Monday 11 April 2005 11:01, Pierre-Frédéric Caillaud wrote: > psycopg ... has a dictfetchall() method which is worth its weight in > donuts ! It's very simple to write one for MySQLdb: def dictfetchall(cursor): '''Takes a MySQLdb cursor and returns the rows as dictionaries.''' col_names = [ d[0] for d in cursor.description ] return [ dict(zip(col_names, row)) for row in cur.fetchall() ] In truth, although postgres has more features, MySQL is probably better for someone who is just starting to use databases to develop for: the chances are higher that anyone using their code will have MySQL than Postgres, and they aren't going to need the features that Postgresql has that MySQL doesn't. IMO, this has changed since only a year or two ago, when MySQL didn't support foreign-key constraints. pgpIeUfcyT5Ux.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Python license (2.3)
On Tuesday 12 April 2005 09:51, Antoon Pardon wrote: > It seems I have to include the following in > my code: > > "Copyright (c) 2001, 2002 Python Software Foundation; >All Rights Reserved" > > Do I understand correctly? You are of course allowed to *add* your own copyright statement: "Copyright (c) 2001, 2002 Python Software Foundation; All Rights Reserved Copyright (c) 2005 Antoon Pardon; All Rights Reserved" pgpzG0ivpEZo9.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Supercomputer and encryption and compression @ rate of 96%
On Thursday 14 April 2005 22:18, Tiziano Bettio wrote: > Actually your script doesn't work on my python distribution... Works fine here - did you decompress the first bit of the python executable? You have to do that before Fredrick's script works... pgpYFHzjRTUoB.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Supercomputer and encryption and compression @ rate of 96%
On Thursday 14 April 2005 22:21, R. C. James Harlow wrote: > You have to do that before Fredrick's script works... Damn - 'Fredrik's' - I accidentally decompressed his name. pgpbUXNRRyNvA.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Supercomputer and encryption and compression @ rate of 96%
On Thursday 14 April 2005 10:27, [EMAIL PROTECTED] wrote: > Supercomputer and encryption and compression @ rate of 96% Dear Sir or Madam, I have received notification that you posted a compression algorithm on the newsgroup comp.lang.python on or about 10:27:26 on the 04/14/2005. I am writing to you to inform you that the algorithm published infringes my "zero-bit compression" algorithm, US Pat No. 13375P33K, which details the transmission of information using no bandwidth to achieve a 100% compression. Please immediately follow up with a retraction of rights to this algorithm or you will hear from my solicitor, Mr J. Peasbody. Yours in law, James Harlow. -- http://mail.python.org/mailman/listinfo/python-list
Re: Piping data into script under Win32
On Saturday 16 April 2005 03:11, runes wrote: > I trying to figure out a way to make a python script accept data output > from another process under Windows XP, but I fail miserably. I have a > vague memory having read this is not possible with Python under > Windows... > > C:\> type countlines.py | python countlines.py > Counted 3 lines. Are you definitely doing this and not: C:\> type countlines.py | countlines.py That will give you the error you're seeing. The example you posted works for me. pgpG1kLcMgQ3U.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Piping data into script under Win32
On Saturday 16 April 2005 03:43, runes wrote: > type countlines.py | python countlines.py = Success > type countlines.py | countlines.py = Failure > > Why doesn't the latter work? Don't quote me on this, but I think it's because invoking countlines.py involves running some sort of wrapper that discards its stdin and stdout. If anyone has a more authorative answer, I'd like to know, because this caught me out too. james. pgp0UPpjLSwGF.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: goto statement
On Thursday 21 April 2005 17:42, Maxim Kasimov wrote: > > Have you tried the triple quote comment technique? > how do use this here: Simple. > sql = ''' > some long query > ''' Change this to: sql = """ some long query """ since you shouldn't be using multiple quoting styles in one module, any more than you should be using multiple casing styles. Then just put single quotes around the place where you want to comment. Not hard, is it? james. pgpEOkrYjHYZq.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Variables
On Sunday 24 April 2005 03:20, Richard Blackwood wrote: > To All: > > Folks, I need your help. I have a friend who claims that if I write: > > foo = 5 > > then foo is NOT a variable, necessarily. This is a really amusingly recursive discussion. Your friend has a piece of knowledge, "what a variable is and is not". He uses the word "variable" to refer to this piece of knowledge. Now, if in some parallel universe people used the word "hairbrush" to refer to this bit of knowledge, that wouldn't stop his argument having validity if he travelled to that universe - if it would then it's already invalidated, as there are more people in *this* universe who use the word variable to refer to foo than there are who insist that it's not correct, by a significant proportion. So by corollary your friend has already argued that one can use many different words to correctly refer to the same concept. I think your friend would also find it hard to disagree that a single word can have multiple meanings, like the example given of "Domain" in maths. I think he would have a similarly tough time saying that these words with multiple meanings were only allowable in maths, not in english or the offshoots of maths like programming. So there's no reason why the concept of what you call a variable and what he calls a variable shouldn't be different. In summary, the words he uses to describe variables are constants, but point at variables, which are different than the constants you use to describe variables, which point at variables, and vary from the variables that his variables point at. And if that last sentence doesn't convince him of the futility of trying to use natual language to communicate precise concepts, nothing will. pgp4lqQYa6ygj.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing data from URL
On Monday 25 April 2005 01:24, Harlin Seritt wrote: > dat = urllib.urlopen(url, 'r').read() Drop the 'r' - urlopen is posting the 'r' to the server, instead of doing what you mean, opening the file read-only. pgpmZ2zcMs1bO.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple tuples for one for statement
On Monday 25 April 2005 04:20, James Stroud wrote: > for a,b,c in zip(tup1, tup2, tup3): >print a >print b >print c or just: for a,b,c in (tup1, tup2, tup3): print a print b print c pgpJ0RNTnCUA3.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple tuples for one for statement
On Monday 25 April 2005 14:34, Ivan Van Laningham wrote: > Hi All-- > > "R. C. James Harlow" wrote: > > or just: > > > > for a,b,c in (tup1, tup2, tup3): > > print a > > print b > > print c > > And this works in Python version??? Ah, reading the replies to the original post, this works but doesn't give the result that the original poster wanted. pgpottbqbjtRP.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Do I need a nested lambda to do this?
On Tuesday 26 April 2005 00:34, raoul wrote: > I can't figure this one out. Trying to be unnecessarily functional I > suspect. With list comprehensions: Python 2.3.4 (#1, Mar 26 2005, 20:54:10) [GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> vals = [1.000,2.344,4.2342] >>> tabs = [((0,1),(0,3),(0,4)), ...((2,2),(3,0),(3,9)), ...((3,4),(6,3),(7,1))] >>> [(tuple([(vals[index],subtab[1]) for subtab in tab])) for index,tab in enumerate(tabs)] [((1.0, 1), (1.0, 3), (1.0, 4)), ((2.3439, 2), (2.3439, 0), (2.3439, 9)), ((4.23420004, 4), (4.23420004, 3), (4.23420004, 1))] -- http://mail.python.org/mailman/listinfo/python-list
Re: large dictionary creation takes a LOT of time.
On Friday 29 April 2005 11:53, Ville Vainio wrote: > > "Kent" == Kent Johnson <[EMAIL PROTECTED]> writes: > > Kent> if frequency.has_key(word): > Kent> frequency[word] += 1 > Kent> else: > Kent> frequency[word] = 1 > > This is a good place to use 'get' method of dict: > > frequency[word] = frequency.get(word,0) + 1 try/except might be fastest of all: http://gumuz.looze.net/wordpress/index.php/archives/2005/04/28/python-dictionary-speed-optimisation/ pgpyyTIumZQjr.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Anyone still using Python 2.5?
Em quarta-feira, 21 de dezembro de 2011 08:50:34, Steven D'Aprano escreveu: On Wed, 21 Dec 2011 07:15:46 +, Chris Withers wrote: Hi All, What's the general consensus on supporting Python 2.5 nowadays? Do people still have to use this in commercial environments or is everyone on 2.6+ nowadays? Centos and Red Hat production systems still use Python 2.4, so yes, absolutely, 2.5 and 2.4 still need to be supported. Not necessarily by package authors though -- that's a matter for them to decide. I'm presently writing a small library which will support 2.4 through 3.2, which isn't as hard as it sounds like, but still isn't exactly fun. If the project were much bigger, I'd drop support for 2.4 and only support 2.5. At least then I could use conditional expressions and __future__ imports. I'm finally getting some continuous integration set up for my packages and it's highlighting some 2.5 compatibility issues. I'm wondering whether to fix those (lots of ugly "from __future__ import with_statement" everywhere) or just to drop Python 2.5 support. What do people feel? It really depends on *your* users, not arbitrary developers. How many of your users are using 2.5? There are still people on 2.5. ESRIs customers (www.esri.com) that rely heavily on Python 2.5, because it ships with a popular ArcGIS release (9.31). The new ArcGIS release uses 2.6, but I can see 9.31 lurking around for another year, at least. Cheers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Controlling kwrite by dcop
On Sunday 08 May 2005 13:41, [EMAIL PROTECTED] wrote: > As you can see you can interact with kwrite from dcop. > Unfortunately I don't have this module in my Python (2.3) nor I have > been able to find it. It's normally installed seperately from the main kde libraries - on gentoo it's a package called dcoppython, that might help you in your search if you're on a different distro. james. pgp55bUjWf3dA.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list