Reserving binary Buffer for struct.pack_into() of exact length

2010-03-19 Thread Hans Müller
Hello, I need some buffers, which are beeing concatenated an then send via the socket() function. My problem is that create_string_buffer() creates a buffer which ist one byte too long (for a \0 char). But when I concatenate some of these buffers to a long one to be transfered, the extra byte

Strange MySQL / sqlite3 Problem with unicode

2009-12-03 Thread Hans Müller
I have a strange unicode problem with mySQL and sqlite. In my application I get a table as a sqlite table which is being compared to an existing mySQL Table. The sqlite drive returns all strings from the table as a unicode string which is Ok. The mysql drive returns all strings as utf-8 coded

Strange unicode / no unicode phenomen with mysql

2009-12-03 Thread Hans Müller
I have a strange unicode problem with mySQL and sqlite. In my application I get a table as a sqlite table which is being compared to an existing mySQL Table. The sqlite drive returns all strings from the table as a unicode string which is Ok. The mysql drive returns all strings as utf-8 coded

Re: Strange unicode / no unicode phenomen with mysql

2009-12-03 Thread Hans Müller
I found the bug, it's in the mysql module. When a column has COLLATE=utf8_bin set, the column is NOT returned as unicode. It's a known bug #541198 Thanks all for reading. Greetings Hans -- http://mail.python.org/mailman/listinfo/python-list

mySQL access speed

2009-11-16 Thread Hans Müller
Hello, I have some programs doing a lot sql IO in some mySQL databases. This works very fine and the DBAPI is quite simple to understand. Now I came to the point where I had to insert millions of lines into a table. My first aproach was to insert the data using executemany(). That's not bad and

How to create an array which can be used also as a dictionary

2009-09-10 Thread Hans Müller
Hello, I have a lot of items having a name and a given sequence. To access these items fast in a sequence order they should be used as a list, but to be fetched fast by name they also should be in a dictionary. Code could be something like this. class item def __init__(name,

Re: How to create an array which can be used also as a dictionary

2009-09-10 Thread Hans Müller
Diez B. Roggisch wrote: Hans Müller wrote: Hello, I have a lot of items having a name and a given sequence. To access these items fast in a sequence order they should be used as a list, but to be fetched fast by name they also should be in a dictionary. Code could be something like

win32pipe

2009-09-03 Thread Hans Müller
Hello, I'd like to play a little with named pipes on windows. For this purpose google told me there is a win32pipe module. My python2.6 on windows doesn't know it - so where can I get ? Does it belong to the std. python for windows or is it a separate package ? Thank a lot, Hans --

Once again, comparison wxpython with PyQt

2009-06-19 Thread Hans Müller
Here we have to select between wxPython and PyQt for a medium size project. In this project several hundred dialogs are to be created. This work will be done by a program generator which has to re-written. The question now is which framework should we use. As far as I could found is PyQt with

Re: Once again, comparison wxpython with PyQt

2009-06-19 Thread Hans Müller
Thanks for all your informative replies. If I understand you right, for a commercial, closed source program I only need a commercial PyQt license for ~ 500€ ? As far as I know I also need a Qt Licenses which is ~3500€ per OS. What is right ? Thanks a lot, Hans --

Funny xmlrpc / linux problem

2009-06-16 Thread Hans Müller
Hello, I found a timing problem while playing with the xmlrpx stuff. I created a very simple server, running on a network node on windows. The client runs on windows or linux. It runs a very simple test function on the server which just echos a passed string. The trip time is beeing measured.

Re: Funny xmlrpc / linux problem

2009-06-16 Thread Hans Müller
Small addition: While tracing the network data I found the server to be the problem, the answer to a request is beeing delayed by about 180ms - no idea why. -- http://mail.python.org/mailman/listinfo/python-list

Re: Funny xmlrpc / linux problem

2009-06-16 Thread Hans Müller
Another addendum... while running again the server code on a linux host, the times are as expected. started... Checking with 100240 time for 10 loops: 2.844000 Checking with 10240 time for 10 loops: 0.39 Checking with 1024 time for 10 loops: 0.078000 Checking with 512 time for 10 loops:

Re: Funny xmlrpc / linux problem

2009-06-16 Thread Hans Müller
Richard, thanks a lot for your hint, that was completely new for me. Nagle's optimisation is definitely a good idea in most cases. By the way, do you have an idea how to access the underlying socket to modify the behavier via the setsockopt function to disable Nagle's algorythm in my special

Seach for encrypted socket wrapper

2009-06-02 Thread Hans Müller
Hello experts, I'm looking for secure way to pass messages from a python program to a c-library in both ways. This scenario is given: display client Calculation module in COBOL (yes, big, old but it works well) (python, wxpython) - Network

Anoying unicode / str conversion problem

2009-01-26 Thread Hans Müller
Hi python experts, in the moment I'm struggling with an annoying problem in conjunction with mysql. I'm fetching rows from a database, which the mysql drive returns as a list of tuples. The default coding of the database is utf-8. Unfortunately in the database there are rows with different

Re: Anoying unicode / str conversion problem

2009-01-26 Thread Hans Müller
Thanks Peter, your answer did the trick. I programed a lot with awk (also a very cool scripting language). So I was focused on the concept a dictionary key has to be string (as in awk). Since it's impossible to use a list as a dictionary key I thought it's also impossible to use a tuple as a key.

Eleganz way to get rid of \n

2008-09-01 Thread Hans Müller
Hello, I'm quite often using this construct: for l in open(file, r): do something here, l contains the \n or \r\n on windows at the end. I get rid of it this way: for l in open(file, r): while l[-1] in \r\n: l = l[:-1] I find this a little bit clumsy, but it

Smal question

2008-07-10 Thread Hans Müller
Hello group, I have some scripts sharing some common functions. So what I'd like to have is a modern include. Of course python does not have (with good reasons) no include statement. But I'm too lazy to create a module which has to be installed into the interpreter for some functions I need to

Re: Smal question

2008-07-10 Thread Hans Müller
Thanks a lot, you made my day. As often in python, it's really simple and useful ! Greetings Hans -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read a binary file into a mysql table

2007-12-18 Thread Hans Müller
Sorry, I found the mistake: There is more than one blob type, blob as a default stores only 64k of data. LONGBLOB has a 4G limit which is Ok for my purposes. Happy Christmas to all, Hans -- http://mail.python.org/mailman/listinfo/python-list

Re: How to read a binary file into a mysql table

2007-12-18 Thread Hans Müller
Hello, thanks a lot for the Binary(). This does the trick, now I can import all my binary data. But now I found the next problem: The Blob is now limited to 65535 Bytes. I love all these stone age (16bit) limits on my 64bit machines... All bigger files a truncated. Has someone an idea how to

How to read a binary file into a mysql table

2007-12-14 Thread Hans Müller
Good morning folks, I cannot read a binary file into a mysql database. Everything I tried did not succeed. What I tried (found from various google lookups...) is this: con = MySQLdb.connect(to server) cur = con.cursor() cur.execute(insert into data values('file1', %s), (open(test.jpg,

DBApi Question with MySQL

2007-12-12 Thread Hans Müller
Hi, I'd like to modify some tables in a database in one transaction. This approach doesn't work: import MySQLdb con = MySQLdb.connect(servernam, user = username, passwd = verysecret, db = test, use_unicode = True, charset = utf8) cursor = con.cursor() con.begin() cursor.execute(delete from