Re: Help with unicode and sqlobject/pysqlite2
qvx wrote: > I really can't seem to make sqlobject/pysqlite2 save my local Easter > European characters. > > I am a Windows-1250 user and I have sys.setdefaultencoding('dbcs') in > my sitecustomize. > > How can I save data like "šdccž"? > This is equivalent to '\x9a\xf0\xe8\xe6\x9e' > > I'm using the latest version of sqlobject from SVN. I can't speak for SQLObject (yet), but if you want to insert text data using pysqlite, you have to either encode them to UTF-8 or use unicode strings. You can convert to unicode strings using unicode('\x9a\xf0\xe8\xe6\x9e', 'dbcs'). As your system default encoding is 'dbcs', even unicode('\x9a\xf0\xe8\xe6\x9e') would be enough. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Zope3 Examples?
Markus Wankus wrote: > [...] Thanks for the reply - maybe I'll give it another shot. I'm currently > demoing Snakelets. Quite a turn in the opposite direction, but small > and super-easy to get going with. [...] I also found Snakelets a pleasure to use and chose it for implementing a clan homepage in early 2005. I'm still very interested in the Python/Web/RDBMS field and tried to follow the developments since then. I didn't actually build anything real, only played a little bit with CherryPy and the megaframeworks built upon, Subway and TurboGears. If I had to choose again, I'd use TurboGears, despite the fact that it's very young and still developing. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Debug Build
Fredrik Lundh wrote: > "Celine & Dave" wrote: > > >>What happens if I build Python with debug option >>(--with-pydebug)? Do I see any changes in my program >>output? What is --with-pydebug good for? > > > from the README: > > --with-pydebug: Enable additional debugging code to help track down > memory management problems. This allows printing a list of all > live objects when the interpreter terminates. And that's why it's very useful for when developing Python extension modules. Not only does it help find reference count problems, --with-pydebug on, Python sometimes also complains earlier if you do "stupid" things in the C code. Or gives a helpful error message before crashing ;-) -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Which SQL module to use?
mrstephengross wrote: > I'd like to do some basic SQL stuff in Python. It seems like there are > a heck of a lot of SQL modules for Python. What's the simplest and > easiest one to use? It looks like pysqlite would be good for getting started with the SQL/Python combo: http://www.pysqlite.org/ It's an embedded database engine, so you do not need to install a separate database server. Just import the module and you have a database engine in your Python: >>> from pysqlite2 import dbapi2 as sqlite Now, let's create a database connection to a local file mydb.db. As this file does not exist, yet, SQLite will create it automatically. >>> con = sqlite.connect("mydb.db") >>> con con is the database connection object. Now, Python needs a cursor object for most database operations, so let's create one: >>> cur = con.cursor() >>> cur We need data to play with, so let's create a simple table: >>> cur.execute("create table persons(id integer primary key, name text)") Now let's populate the table: >>> cur.execute("insert into persons(name) values (?)", ("David",)) >>> cur.execute("insert into persons(name) values (?)", ("Rachel",)) >>> cur.execute("insert into persons(name) values (?)", ("Simon",)) >>> Commit the changes, so they're visible to other database connections that would open the file mydb.db. >>> con.commit() Now let's try some queries: >>> cur.execute("select id, name from persons") >>> cur.fetchall() [(1, u'David'), (2, u'Rachel'), (3, u'Simon')] >>> Note that SQLite returns Unicode strings for TEXT. Next, let's try to use a parametrized query. pysqlite uses the qmark style, so you just put ? as placeholders: >>> whichname = "Rachel" >>> cur.execute("select id, name from persons where name=?", (whichname,)) >>> cur.fetchall() [(2, u'Rachel')] That's enough for a start I think. Maybe I could whet your appetite. The pysqlite documentation has a few other small examples at http://initd.org/pub/software/pysqlite/doc/usage-guide.html#brief-tutorial But nothing extensive, yet. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Mysql, insert NULL
Python_it wrote: > I know how to insert values in a database. > That's not my problem! > My problem is how i insert NULL values in de mysql-database. > None is een object in Python and NULL not. > None is not converted to NULL? > Table shows None and not NULL! As Laszlo wrote, "None will be converted to NULL" for the Python => SQL direction. And also, NULL will be converted to None for SQL => Python direction. And to avoid unneccessary if-then-else you should follow his advice and use parametrized queries. I. e. cursor's execute method has two parameteres: 1) SQL query with placeholders 2) parameters For example: var1 = "Joe's dog" cur.execute("insert into mytable(col1) values (%s)", (var1,)) var1 = None cur.execute("insert into mytable(col1) values (%s)", (var1,)) if you use MySQLdb (the most sensible choice for a MySQL Python database adapter). Because MySQLdb uses the pyformat param style, you use the %s placeholder always, no matter which type your parameter will be. Also, the tip to read the DB-API specification http://www.python.org/peps/pep-0249.html is a good one in my opinion. It really pays off to learn how to do things the DB-API way. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: PyObject_New
Jeremy Moles wrote: > [...] What I'm trying > now is the following: > > PyObject* obj = _PyObject_New(&PyType_MyType); > obj = PyObject_Init(obj, &PyType_MyType); > > ... > > return obj; > > When "obj" gets back to the interpreter, Python sees it (or rather, it's > __repr__) in accordance with what it "should" be. However, any attempt > to USE the object results in a segfault. I feel my problem is simply > that I'm not allocating "obj" correctly in the C++ function. > > If anyone has any advice, I would really appreciate it. When I looked for info on this, I didn't find any good documentation, either. I'm currently using code like the following in pysqlite (http://initd.org/tracker/pysqlite/browser/pysqlite/trunk/src/connection.c?rev=154): 126 if (factory == NULL) { 127 factory = (PyObject*)&CursorType; 128 } 129 130 cursor = PyObject_CallFunction(factory, "O", self); So, basically I'm just calling the type like any other callable object. I don't remember if there was a reason why I didn't use PyObject_CallObject instead, at the time ... In any case, this approach worked fine for me. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: subtyping a builtin type in a C extension
shawn wrote: > I am trying to make a subtype of a string. Initially it will have no > new methods or attributes, the C equivalent of: > > class myStr(str): > pass > > I have experimented a bit, but am currently making a mess of it. Does > anybody have an example they can point to of inheriting from a builtin, > or a suggestion to point me in the right direction? The Python source distribution contains an example module xxsubtype that shows how to subclass builtins: http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/xxsubtype.c?rev=2.15.2.1&view=markup -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Psycopg2 date problems: "Can't adapt"
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve Holden wrote: > I'm trying to copy data from an Access database to PostgreSQL, as the > latter now appears to work well in the Windows environment. However I'm > having trouble with date columns. [...] > Here's the problem in a nutshell: > > >>> d > > >>> ocurs.execute("DELETE FROM Lines") This repr looks like a mxDateTime object. psycopg does include adapters for mxDateTime, but in order for them to be built, the mxDateTime sources and headers must be made available at psycopg build time (because it interfaces mxDateTime at the C extension level, unlike most if not all other Python DB-API adapters). A quick look at its setup.py reveals a have_mxdatetime variable and a check that decides wether to build with mxDateTime support or not. So, if it does not find mxDateTime, it builds without support for it. Which is apparently what you're experiencing. HTH, - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDWTFOdIO4ozGCH14RAgMyAJkB7gV88qhsmLmiMTCKXEDCbmjclACdEiW0 S56KM6ArQRUqP+jel2dC14M= =cExi -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Tricky Areas in Python
PyPK wrote: > What possible tricky areas/questions could be asked in Python based > Technical Interviews? I would try to check if the applicant understands the Python data model: http://docs.python.org/ref/objects.html Because I thinkt that's fundamental to understanding the Python language and understanding complexity of operations. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: PDO and database abstraction
Luiz Geron wrote: > Hi all, > I'm testing the PDO wrapper to database modules [1] and I'm wondering > how few things like this there are around. Actually there are several Object-Relation Mappers (ORM) for Python, and also a few other attempts to provide a more convenient layer on top of DB-API modules. This wiki page has links: http://wiki.python.org/moin/HigherLevelDatabaseProgramming > My problem, actually, is the paramstyle of modules. That problem exactly what these solutions try to solve, this and multiple SQL dialects and handling types like date etc. for multiple backends. > I want to use kinterbasdb in the same code I use > cx_oracle, for example, but paramstyle changes from one to other, than > I searched for things like this and found nothing really usefull. The > problem with PDO is that it was so dificult to find, since a few people > seems to use it, and I haven't yet figured how to change the paramstyle > on it, so I want to ask: Do you use a thing like this that you would > recommend to me? I always wrote my own thin layer on top of DB-API modules and used it to implement a *specific* database interface for my applications. This would then have one or more database backends. Actually never more than two so far. If you want to go for a more popular ORM, you can try out SqlObject. But it doesn't have Oracle support, yet. There were patches and there are apparently again new attempts to integrate Oracle support, but nothing official/finished yet apparently. Personally, I recently checked out different ORMs for Python one afternoon. Only superficially, but here's my biased uninformed opinion. - SqlObject (1) has an active community, and its use in Subway and TurboGears will create even more momentum for it. By looking at its code (for hacking in Oracle support, which I managed to do for a one-table test case), I found it to have *a lot* features, including caching and others. I don't particularly like that, I'd prefer a thin-to-medium layer myself. - There was something to Modeling (2) I didn't like. It's just a gut feeling that it tries to do too much for my taste. - PyDO2 did work with Oracle out of the box, the SQLite and PostgreSQL adapters looked reasonable too from a quick code inspection. It does seem to do one thing and do it right, which is a philosophy I like in libraries and wrappers. If I'm to use a ORM for a future project, I'd first go with PyDO2. HTH, -- Gehard (1) http://sqlobject.org/ (2) http://modeling.sourceforge.net/ (3) http://skunkweb.sourceforge.net/PyDO2/manual.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Tricky Areas in Python
bruno modulix wrote: > beza1e1 wrote: >>well, list comprehension is Python 2.4 > > 2.2.x IIRC List comprehensions were introduced in Python 2.0, according to the "What's new in ..." document at http://www.amk.ca/python/2.0/index.html#SECTION00060 -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: tool for syntax coloring in html
Xah Lee wrote: > in some online documentations, for examples: > > http://perldoc.perl.org/perlref.html > http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme-Z-H-17.html > http://www.haskell.org/hawiki/HaskellDemo > > the codes are syntax colored. > > Is there a tool that produce codes in html with syntax coloring? I use SilverCity and this recipe to produce colored code listings for the pysqlite documentation: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252170 This is the documentation source: http://initd.org/svn/pysqlite/pysqlite/trunk/doc/usage-guide.txt This is the result: http://initd.org/pub/software/pysqlite/doc/usage-guide.html HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Scanning a file
[EMAIL PROTECTED] wrote: > I want to scan a file byte for byte [...] > while True: > ch = inputFile.read(1) > [...] But it is very slow. What is the fastest way to do this? Using some > native call? Using a buffer? Using whatever? Read in blocks, not byte for byte. I had good experiences with block sizes like 4096 or 8192. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem With Insert with MySQLdb
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Mitchell wrote: > Hello, > > I am a complete beginner with Python. I've managed to get mod_python up and > running with Apache2 and I'm trying to a simple insert into a table in a > MySQL database. > > I'm using the MySQLdb library for connectivity. I can read from the database > no problem, but when I do an insert, the value never gets added to the > database, even though there is no error, and the SQL is fine (I print out > the SQL statement in the function). When I copy and paste the sql from my > browser and insert directly into MySQL, it works fine. > [...] Am I doing something obviously incorrect here? It appears you forgot to call .commit() on the connection to commit your transaction. From what you tell, it also looks like the MySQL commandline tool defaults to autocommit (i. e. each statement is wrapped in an implicit BEGIN ... COMMIT. If you have no idea what a transaction is or what the heck the BEGIN, COMMIT or ROLLBACK commands are for (corresponding to .commit() and .rollback() methods of the DB-API2 connection object, BEGIN is issued implicitly), then the MySQL documentation will probably answer that. HTH, - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDZWBndIO4ozGCH14RAuuKAJ9MiUn39dfd0FMclnYBFkXufN/wzwCdG7s4 6Bxj6HdyBbAz7u5O5tu0m7E= =FXrV -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Need Python Pro for Help!! Plzz
Alex Hunsley wrote: > [EMAIL PROTECTED] wrote: > >>Need python Pro at [EMAIL PROTECTED] , if u wanna help, > [...] > 2) Why should someone willing to help you enter into a private email > discussion? [...] Actually, it's a Google Group mailing list (formerly eGroups): http://groups.google.de/group/newtopython?lnk=sg&hl=de Maybe the people who set it up didn't know that there is perfectly good mailing list for the same topic already: http://www.python.org/mailman/listinfo/tutor -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle, is anything selected?
Damjan wrote: > This is a simplification of the program > > c = db.cursor() > while 1: > c.execute('select ') > smtp = SMTP(MAIL_HOST, 25, 'localhost') > for address, subject, body in c: > smtp.sendmail() > smtp.quit() > time.sleep(60) > > now if the select doesn't return any rows, there's no need to connect to the > mail server. I'd like to avoid that unnecessary step. [...] Well, something like: c = db.cursor() while 1: smtp = None c.execute('select ') for address, subject, body in c: if not smtp: smtp = SMTP(MAIL_HOST, 25, 'localhost') smtp.sendmail() if smtp: smtp.quit() time.sleep(60) should do that. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and MySQL
Thomas Bartkus wrote: > [some posters having the idea that MySQLdb works without a C extension] > Okay - I neglected to look at the [site-packages] directory itself. Here I > do find [_mysql.pyd] full of binary code. A MySQLdb related file that > doesn't seem to have a corresponding file with Python source code. Mea > culpa! This is on MS Windows [C:\Python23]. > > But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a > Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while > there are other file extensions, everything seems to have a corresponding > [.py]. MySQLdb is based on a C extension module called _mysql on all platforms. The C extension modules have the extension ".pyd" on Windows by default, and ".so" on Unix. It would in theory be possible to do without a C extension, but then you would have to implement the MySQL client-server protocol (http://dev.mysql.com/doc/internals/en/client-server-protocol.html) in Python, for example using the socket module. Implementing a pure-Python package to interface a database by implementing the client-server protocol in Python has been done already for PostgreSQL, but I don't think it has been done for MySQL, yet. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: how to compile c-extensions under WinXP?
[EMAIL PROTECTED] wrote: > What should I do to be able to compile C-extensions (with python 2.4, > winXP)? I get an error message, approximately "The .NET Framework SDK > needs to be installed"; I tried to get something from the Microsoft web > site, but maybe not the right version (or didn't set some variables), > since the error remains. Could you please help me (it will need some > patience with a computer newbie)? I managed to do it with the instructions at http://www.vrplumber.com/programming/mstoolkit/ -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Distributed Cache Server?
[EMAIL PROTECTED] wrote: > Does anyone know if a "distributed caching system" has been developed > for use with Python? I've seen mention of memcached, but was really > after something natively python. [...] Too bad, because memcached implements all the difficult parts already (like failover if one node dies), has Python bindings: ftp://ftp.tummy.com/pub/python-memcached/ and just plain works. > [...] I've started development of such a system, but am wondering if > something already exists out there. I don't know of any pure-Python equivalent. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and PL/SQL
vb_bv wrote: > Does Pyton PL/SQL programming language of Oracle support? Python supports calling Oracle PL/SQL procedures. Here's an example using the cx_Oracle database adapter: >>> import cx_Oracle >>> con = cx_Oracle.connect("outlinetest/[EMAIL PROTECTED]") >>> cur = con.cursor() >>> cur.execute(""" ... BEGIN ... PKG_Test.Test; ... END; ... """) cx_Oracle also works with all types I needed, including passing ARRAYs to stored procedures, and getting REFCURSORs back. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and PL/SQL
infidel wrote: > vb_bv wrote: > >>Does Pyton PL/SQL programming language of Oracle support? >> > PL/SQL is only supported *inside* Oracle databases. Python can be used > to call PL/SQL procedures (I recommend the cx_Oracle module), but you > can't run Python inside the database like PL/SQL. If one is really really really insisting on running Python code inside an Oracle database, I think it could be done: you can write Oracle stored procedures in C libraries, Java libraries and even .NET libraries (10g on win32). And there are Python implementations for C, Java and .NET. So much for the theory. In my not so humble opinion, instead of all this fancy stuff, you will be better off writing your stored procedures in PL/SQL, which is a very good language for manipulating data, and writing portable, efficient and maintainable server-side database code. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle callproc output parameters
infidel wrote: > I have a stored procedure that has a single output parameter. Why do I > have to pass it a string big enough to hold the value it is to receive? > Why can't I pass an empty string or None? > [...] > Am I missing something obvious here? You have to use variable objects to the callproc() that will hold the output values. This is an example using three VARCHAR output parameters. HTH, -- Gerhard import cx_Oracle con = cx_Oracle.connect("user/[EMAIL PROTECTED]") cur = con.cursor() l_SchemaName = cur.var(cx_Oracle.STRING) l_DbName = cur.var(cx_Oracle.STRING) l_DomainName = cur.var(cx_Oracle.STRING) cur.callproc("TP_Lookup.GetSchema", (l_SchemaName, l_DbName, l_DomainName)) print "You are connected to", print "the schema", l_SchemaName.getvalue(), print "at %s.%s" % (l_DbName.getvalue(), l_DomainName.getvalue()) -- http://mail.python.org/mailman/listinfo/python-list
Re: Hi, from my login i want to login as a other user ,
sumi wrote: > Hi, i am very new to python , it is just 2 days i started reading abt > it. I did not understand the above statement. what i want to do is , i > want to login as a super user eg : > $su xyz , and then i need to enter the passwd, i want to do these steps > using python , how can i do it?? You're probably looking for the setuid() and setgid() functions in the module `os`. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Winpdb question
mclaugb wrote: > Is there any way to either restrict the number of variables displayed in the > Globals or Locals section. It is a pain having to search through this list > all of the time just to look at the values of variables in my program. IMO, if you have too many locals or globals then that's a sign that you should structure your application better with more functions and classes ... -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Lie Hetland book: Beginning Python..
Vittorio wrote: > [...] > Nonetheless, I was unable to find any documentation about such a > different behaviour between Pysqlite and Pysqlite2; from my beginner > point of view the Pysqlite (Magnus' version) paramstyle looks a better > and more pythonic choice and I don't grasp the Pysqlite2 developers' > intentions deviating from that way. The reason why pysqlite 0.x/1.x used paramstyle "pyformat", based on Python string substitution for SQL parameters is that at the time pysqlite was started, SQLite 2.x did not have any support for parameter binding. So we had to "fake" it in Python, just like the MySQL interface does (for the same reasons). Later SQLite 2.x versions and of course SQLite 3.x supported real bound parameters and pysqlite2 was developed from scratch to benefit from them. SQLite 3.x supports both qmark and named paramstyles, so you can use question marks *or* named parameters: >>> from pysqlite2 import dbapi2 as sqlite >>> con = sqlite.connect(":memory:") >>> cur = con.cursor() >>> cur.execute("select 2*?", (14,)) >>> cur.fetchone() (28,) >>> >>> cur.execute("select 2 * :x", {"x": 14}) >>> cur.fetchone() (28,) >>> >>> x = 14 >>> cur.execute("select 2 * :x", locals()) >>> cur.fetchone() (28,) >>> I've also once written a wrapper using pysqlite 2.x's hooks that allows you to use the "format" paramstyle with pysqlite 2.x, so you can reuse more code that was originally written against pysqlite 0.x/1.x: from pysqlite2 import dbapi2 as sqlite class PyFormatConnection(sqlite.Connection): def cursor(self): return sqlite.Connection.cursor(self, PyFormatCursor) class PyFormatCursor(sqlite.Cursor): def execute(self, sql, args=None): if args: qmarks = ["?"] * len(args) sql = sql % tuple(qmarks) sqlite.Cursor.execute(self, sql, args) else: sqlite.Cursor.execute(self, sql) con = sqlite.connect(":memory:", factory=PyFormatConnection) cur = con.cursor() cur.execute("create table test(a, b, c)") cur.execute("insert into test(a, b, c) values (%s, %s, %s)", ('asdf', 4, 5.2)) cur.execute("select a, b, c from test where c <> %s", (4.27,)) print cur.fetchone() cur.close() con.close() > I would be very grateful if someone would cast a light over > Pysqlite/Pysqlite2 discrepancies. I think about the only place I wrote a bit about the differences was in the pysqlite 2.0 final announcement: http://lists.initd.org/pipermail/pysqlite/2005-May/43.html -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: python + ODBC + Oracle + MySQL - money
Grig Gheorghiu wrote: > In my testing, I need to connect to Oracle, SQL Server and DB2 on > various platforms. I have a base class with all the common code, and > derived classes for each specific database type using specific database > modules such as cxOracle, mxODBC and pyDB2. The derived classes are > pretty thin, containing only some syntax peculiarities for a given > database type. The code is clean and portable. So maybe you're lucky that all your database modules use the same access to query parameters. MySQLdb and cx_Oracle would be different in that MySQLdb has paramstyle = "format" and cx_Oracle has paramstyle = "qmark/named", i. e. to query a specific record of the person table you would use p_id = 4711 cur.execute("select firstname from person where person_id=%s", (p_id,)) using MySQLdb, and: cur.execute("select firstname from person where person_id=?", (p_id,)) using cx_Oracle. Now, probably a lot of people have written wrappers for DB-API modules that translate one paramstyle to the other. The most sensible solution is to translate the format/pyformat one to others. Often, one other solution is to use a higher-level database interface uses your database modules internally, but has the same consistent interface for the outside. In my recent evaluations, I liked PyDO2 for this (http://skunkweb.sourceforge.net/pydo2.html). Unlike SQLObject, it is able to use MySQL and Oracle now, though there is work underway to add Oracle support to SQLObject. OTOH, the advice to use MySQLdb and cx_Oracle directly is probably a good one, especially for a newcomer to Python. It's a good way to learn Python and learning the Python DB-API is a good idea if you want to do a database application in Python. You can use higher-level interfaces (or write them yourself) later on. And if this is serious work with business value, then just buying a mxODBC license and go on with the real problem is probably the most sensible solution. You can use the time saved for learning Python, then, which is perhaps more fun :-) Cheers, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Script to export MySQL tables to csv
Jandre wrote: > To anyone that can help > > I have 2 MySQL databases that contain large amounts of tables. I need > to be able to compare the data in the tables with older/newer versions > of the tables. I figured the easiest way would be to get the info in > csv format and then run a comparison. [...] I think the easiest way to compare tables in a SQL-based database is using SQL ... What about exporting the tables from the databases, importing those you want to compare into one database and then using set-operations in SQL using MINUS, INTERSECT. For example: select c1, c2, c3 from table1 intersect select c1, c2, c3 from table2; -- return data common in both tables select c1, c2, c3 from table1 minus select c1, c2, c3 from table2; -- data only in table1 etc. You can export specific tables from a MySQL database using the mysqldump commandline tool and then load them into the other database. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: how to start a process and get it's pid?
Yves Glodt wrote: > Hello, > > another question rose for me today... > > Is there a way to start an external process, in it's own context (not as > the exec-() functions do), and get it's pid...? [...] Check out the subprocess module if you're using Python 2.4. Otherwise, you can always use os.spawn*, for example: >>> os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe") 1944 HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: DB API specification of .rowcount and/or execute
[EMAIL PROTECTED] wrote: > Hi, > > Should execute() be allowed to execute multiple operations? [...] You best ask such questions on the DB-SIG. I say "no" and I think most people there will agree. Most DB-API modules will accept multiple statements, but that's an implementation artifact, and not intended by the DB-API. FWIW I specifically implemented a check in pysqlite that will raise a Warning if you use multiple statements in execute(many) and provided a nonstandard executescript() method for those who really want to execute multiple statements. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: syntax errors while building pypgsql
Tin Gherdanarra wrote: > Hallo, > > I'm trying to install pypgsql. However, I get syntax errors > while compiling the C sources. The following excerpt > from pgconnection.h looks a little funny to me: > > typedef struct { > PyObject_HEAD /* Here is the syntax error, and rightly so */ > [...] > I don't know what PyObject_HEAD or PGconn is, > but if they are types, a syntax error is justified here: [...] I don't think that's the real error. Are there any error messages *before* that? Like the compiler can't find "Python.h" or something? That would be an indication that you do not have the python-devel package installed. Btw. the Debian package of pyPgSQL is called python-pgsql, so an apt-get install python-pgsql should do. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao Language v.0.9.6-beta is release!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Micah Elliott wrote: > On Dec 02, Dave Hansen wrote: > >>Python recognizes the TAB character as valid indentation. TAB >>characters are evil. They should be banned from Python source code. > > AGREE! AGREE! AGREE! > >>The interpreter should stop translation of code and throw an >>exception when one is encountered. > > > You could file a "Parser/Compiler" Feature Request for this [...] Read PEP 666 first. - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDkLJWdIO4ozGCH14RAiOyAJ4gNZrf5rjv5Cqk2cj/hFGXRaeCZwCdEL/X ITGPnj6tXblSY1r04zS5djY= =z37M -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: psycopg simplest problem
Glauco wrote: > [...] > Gerhard thank you very much, this example explain me some idea, but > anyway don't resolve the core question. > In you example when dateVal is a None or textVal is none. > argument x must be DateTime, not None. > so i must manipulate for the empty string or None cases No, you don't. If you leverage the two-parameter form of .execute(many), your Python DB-API module will handle the None => NULL case for you transparently. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: How to protect Python source from modification
Frank Millman wrote: > Hi all > > I am writing a multi-user accounting/business system. Data is stored in > a database (PostgreSQL on Linux, SQL Server on Windows). I have written > a Python program to run on the client, which uses wxPython as a gui, > and connects to the database via TCP/IP. > > The client program contains all the authentication and business logic. > It has dawned on me that anyone can bypass this by modifying the > program. As it is written in Python, with source available, this would > be quite easy. My target market extends well up into the mid-range, but > I do not think that any CFO would contemplate using a program that is > so open to manipulation. [...] My suggestion is to use py2exe or cx_Freeze to package your application. It's then not as trivial to modify it. Btw. you don't need to ship the .py source code files, it's enough to ship only .pyc bytecode files. Using py2exe it's not even obvious that your application is written in Python at all. It's not a silver bullet, but at least it makes recompiling/modifiying your app not easier than with Java (and/or .NET I suppose). That being said, even if you continue with the GUI approach, it may still be a good idea to factor out all the business logic in a separate module so you can eventually switch to a web application or a three-tier model without too much effort. Also, there's no need at all to put in countless hours implementing your own network protocol. If you really want to separate client and app server, then why not use something simple as PyRO, or even XML/RPC. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a database. Sugestions?
Ed Hotchkiss wrote: > On 15 Sep 2005 21:31:27 -0700, *gsteff* wrote: > > SQLite rocks, its definitely the way to go. Its binary is around 250K, > but it supports more of the SQL standard than MySQL. It CAN be thread > safe, but you have to compile it with a threadsafe macro enabled. [...] > > Is this for running an SQL database, then using a separate python > module to access the database? SQLite being an embedded database, if you use it via pysqlite (http://pysqlite.org/), it is part of your Python application, i. e. there is no separate SQL server and client, the SQL engine is just part of your application and the data is located in one local file. pysqlite itself is a little larger than SQLite, of course, for example the statically linked binary extension module on Windows is 331.776 bytes in the latest version: C:\>dir c:\Python24\lib\site-packages\pysqlite2 Datenträger in Laufwerk C: ist Lokaler Datenträger Volumeseriennummer: 8C7F-873C Verzeichnis von c:\Python24\lib\site-packages\pysqlite2 26.08.2005 11:00 . 26.08.2005 11:00 .. 16.05.2005 21:11 2.525 dbapi2.py 12.09.2005 10:49 2.425 dbapi2.pyc 12.09.2005 10:49 2.425 dbapi2.pyo 26.08.2005 11:00 test 12.09.2005 00:56 331.776 _sqlite.pyd 16.05.2005 21:11 1.016 __init__.py 12.09.2005 10:49 131 __init__.pyc 12.09.2005 10:49 131 __init__.pyo 7 Datei(en)340.429 Bytes -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: why is http://pysqlite.org down ?
[EMAIL PROTECTED] wrote: H! I'm trying things with databases and Python 2.4 for windows2000. And now I want to try pysqlite. but http://pysqlite.org/ is down It is in the process of being made an alias for the real new home: http://initd.org/projects/pysqlite and http://pysqlite.sourceforge.net/ redirect to pysqlite.org does someone know if this is the latest version http://sourceforge.net/projects/pysqlite/ pysqlite 2.0 The latest official version is still 2.0alpha1, the Subersion repository contains some updates, and these days I'm working an finally getting it consistent enough for a 2.0alpha2. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: fastest postgresql module
Timothy Smith wrote: [...] is there anyway i can check is it true psycopg is much faster or is it all hyperboll The overhead of psycopg per cursor row is a lot less. So it makes a difference if you fetch *a lot* of data. Anyway, if you don't have a performance problem, you don't need to care ;-) Yes there is a way to try it out, install it and compare :-P As I said, there is a win32 version of psycopg if that's the only platform you have access to: Google - first hit: http://www.google.de/search?hl=de&q=psycopg+win32&btnG=Google-Suche&meta= => http://www.stickpeople.com/projects/python/psycopg/ -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: from vb6 to Python
MarcoL wrote: Hello, I am a VB6 programmer and I would like to learn a new high level language (instead of restarting from scratch with .NET), wich is opensource and cross-platform, in order to develop cross-platform business applications I think Python is the most suitable language for the scope. My question are: - Which version of python is more suitable for creating cross-platform GUI's? I've herard of PyGTK, wxPython, PyQT, tk, Anygui.. It's a matter of taste. I like wxPython best. It would probably be different if PyQT was also open-source on win32. - What is the best IDE/RAD for Python (written in Python and OpenSource) You should check out ERIC/Qt. If you need to target Windows, then you can consider buying a win32 Qt/PyQt license. The best IDE I've seen so far is WingIDE (commercial). - Does exist a tool (written in Python and OpenSource) like Crystal Report for creating business reports? Reportlab is the closest I know. - Does exist a tool (written in Python and OpenSource) for makeing tables, view, querys, relation of a database and generate the SQL script? Rekall is the closest. - Is it possible, from Python, to work with sqlite? And with MsAccess? Yes. pysqlite (http://pysqlite.org/), and pyado, if by MsAccess you mean using the JET engine via ADO. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Lowest hassle Python web server?
kanzen wrote: I keep telling my friends that Python rocks. Now it's time to put my money where my mouth is. I'm about to start writing a server for a phone based game. It needs to handle simlpe requests from some Java code running on the phone at a fairly low transaction rate. There will also be a simple web site allowing users to edit preferences and so forth. I have just enough Python experience to decide that I prefer it over Java for this job. It'll be on a Linux box that I have full control over. I can see from FAQs that there are several possible ways of doing web server work in Python, e.g. Twisted or mod_python in Apache, etc. So I'm wondering: - Could you recommend a solution you've found to be the most convenient? I've tested a few, and when it finally came that I wanted and needed to do web application development in Python for real, I decided to use Snakelets. So far, I find it a very convenient way to write web applications. It's also very close to how Java servlets/JSP pages work. FWIW, the other frameworks I've tested thoroughly were Quixote and WebWare. - Does threading cause any more of a hassle in Python than Java? - Is there anything similar to JSP in Java? Snakelets Ypages come close to JSP. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Lowest hassle Python web server?
Larry Bates wrote: [...] You might want to take a look a Medusa. It is the basis for the web server that is bundled in Zope. Medusa is just an asyncore framework, and not something you can develop web apps with. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: [newbie] smtplib.login()?
PA wrote: On Mar 25, 2005, at 11:04, PA wrote: What am I doing wrong? Why is the user name being encoded twice? Ok... turns out that this is/was a bug in the python smtplib as recently as Dec 6 2004: Patch #1075928: AUTH PLAIN in smtplib. "smtplib can not log in to some server using command AUTH PLAIN, it sends ``user\0user\0pass'' to the server, but ``\0user\0pass'' has better compatibility." I'll try to look into it. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: change extensions
Bob Then wrote: how can i change all files from one extension to another within a direcory? Using os.listdir, os.path.split and os.rename. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
pysqlite 2.8.0 released
NEW FEATURES - No new features, but tons of bugfixes. These mean that things now work that didn't before: - Transactional DDL now works - You can use SAVEPOINTs now BUILD PROCESS - Python 2.7.x is now required. If trying to use it with Python 3, print a useful error message. Integrated all fixes from the sqlite3 module in Python 2.7.10. MAJOR IMPROVEMENTS - Completety got rid of statement parsing. We now use SQLite functions to determine if a statement modifies the database or not. If a statement modifies the database, then we implicitly start a transaction. For backwards compatibility reasons, we do NOT implicitly start a transaction if we encounter a DDL statement. You can, however, now have transactional DDL if you want to: cur = con.cursor() cur.execute("begin") cur.execute("create table foo(bar)") con.rollback() This also means that people can now finally use SAVEPOINTS. - Use sqlite3_get_autocommit() to determine if we are within a transaction instead of trying to be smart. - Switch to v2 statement API. This simplified the code and will increase stability. MINOR IMPROVEMENTS - You can use unicode strings as index for Row objects. BUGFIXES - Fixed a regression: statements should not be reset after a commit. GENERAL CLEANUP AND DEPRECATIONS - Since december 2005, row_factory is a feature of the Connection class instead of the Cursor class. It was kept in the Cursor class for backwards compatibility. Now it was time to finally remove it from the Cursor class. - DEPRECATE converters and adapters. - DEPRECATE text_factory. - Remove compatibility workarounds for old Python versions. - Remove workarounds for old SQLite versions. - Remove apsw related code. -- https://mail.python.org/mailman/listinfo/python-list
Re: [python-sqlite] Re: pysqlite 2.8.0 released
Yes, I forgot to "setup.py sdist upload". It's fixed now. Sorry for the trouble. I'm of course looking forward to hear if SQLAlchemy still works ok with this release. On Wed, Aug 19, 2015 at 10:10 PM, wrote: > Hi Gerhard - > > is the download missing? On Pypi I see 2.8.0 is registered but no > download file: > > https://pypi.python.org/pypi/pysqlite/2.8.0 > > pip fails: > > $ ./bin/pip install pysqlite==2.8.0 --upgrade --force > Collecting pysqlite==2.8.0 > Could not find a version that satisfies the requirement pysqlite==2.8.0 > (from versions: 2.5.6, 2.6.0, 2.6.3, 2.7.0) > Some externally hosted files were ignored as access to them may be > unreliable (use --allow-external to allow). > No distributions matching the version for pysqlite==2.8.0 > > > > On Tuesday, August 18, 2015 at 8:17:46 PM UTC-4, Gerhard Häring wrote: >> >> NEW FEATURES >> >> - No new features, but tons of bugfixes. These mean that things now work >> that >> didn't before: >> - Transactional DDL now works >> - You can use SAVEPOINTs now >> >> >> BUILD PROCESS >> >> - Python 2.7.x is now required. If trying to use it with Python 3, print a >> useful error message. Integrated all fixes from the sqlite3 module in >> Python >> 2.7.10. >> >> >> MAJOR IMPROVEMENTS >> >> - Completety got rid of statement parsing. We now use SQLite functions to >> determine if a statement modifies the database or not. If a statement >> modifies the database, then we implicitly start a transaction. For >> backwards >> compatibility reasons, we do NOT implicitly start a transaction if we >> encounter a DDL statement. >> >> You can, however, now have transactional DDL if you want to: >> >> cur = con.cursor() >> cur.execute("begin") >> cur.execute("create table foo(bar)") >> con.rollback() >> >> This also means that people can now finally use SAVEPOINTS. >> >> - Use sqlite3_get_autocommit() to determine if we are within a transaction >> instead of trying to be smart. >> >> - Switch to v2 statement API. This simplified the code and will increase >> stability. >> >> MINOR IMPROVEMENTS >> >> - You can use unicode strings as index for Row objects. >> >> >> BUGFIXES >> >> - Fixed a regression: statements should not be reset after a commit. >> >> >> GENERAL CLEANUP AND DEPRECATIONS >> >> - Since december 2005, row_factory is a feature of the Connection class >> instead >> of the Cursor class. It was kept in the Cursor class for backwards >> compatibility. Now it was time to finally remove it from the Cursor >> class. >> - DEPRECATE converters and adapters. >> - DEPRECATE text_factory. >> - Remove compatibility workarounds for old Python versions. >> - Remove workarounds for old SQLite versions. >> - Remove apsw related code. >> >> -- > > --- > You received this message because you are subscribed to the Google Groups > "python-sqlite" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to python-sqlite+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing the availability of a module
Bo Peng wrote: > Dear list, > > Is there a better way than doing > > try: >import aModule > except: >has_aModule = False > else: >has_aModule = True > > The main concern here is that loading aModule is unnecessary (and may > take time). No, there is not really a better way. You *could* check for the existance of files, but a file existing and it really being successfully loadable as a module are not the same. Besides, it is a lot of work to reimplement half the Python import machinery just for checking for all kinds of files. If you're serious about it, you also need to cope with modules loadable from ZIP files, and with .pth files, etc. This is not fun to program, and you're really better off just checking for a successful import like you're doing now. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE; Try python beta
Lonnie Princehouse wrote: > Pretty neat =) > > But aren't you concerned about security? Letting anybody execute > arbitrary Python expressions (and therefore also arbitrary system > commands?!) on your box --- even from within a FreeBSD jail --- seems a > bit dangerous. I found out about the FreeBSD jail myself, too ;-) Removing __import__ from the builtins would make such detective work much harder, though ;-) -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.1.0 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 pysqlite 2.1.0 released === I'm pleased to announce the availability of pysqlite 2.1.0. This is a major release with many new features and some internal changes. While the code was tested by a few people who tracked Subversion, users are still adviced to test their applications intensively with the new release before upgrading them to pysqlite 2.1.0. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. === CHANGES === Statement caching = Planned since the start of the pysqlite2 development, the most difficult to implement feature has now been implemented: transparent statement caching. What is statement caching? Every SQL engine has a COMPILE and EXECUTE phase. In older pysqlite releases, every SQL statement (except for executemany) was always COMPILED and EXECUTED. With statement caching, pysqlite can transparently optimize away the COMPILE step. The statement cache is implemented using a LRU cache with a default capacity of 100. The cache is per connection - it's capacity can be set when opening a connection: con = sqlite.connect(..., cached_statements=30) In a nutshell, this means the 100 most used SQL statements in your application will only have to be COMPILED once by the SQLite engine. This will of course only work well if you use the parameter-form of the execute() method, i. e. for: cur.execute("insert into foo(bar) values (?)", ("xy",)) cur.execute("insert into foo(bar) values (?)", ("ab",)) the SQL statement "insert into foo(bar) values (?)" will then only be compiled once. Users have seen significant performance improvements with the statement caching in pysqlite 2.1.0: http://lists.initd.org/pipermail/pysqlite/2005-November/000234.html More flexibility for TEXT data == Until now, pysqlite would always return Unicode strings for text data, unless you did some crazy trickery. If you prefer to retrieve text data as Python bytestrings or a different type, you can now set a text_factory callable per connection: con.text_factory = str # ... to always return bytestrings An optimized shortcut has been enabled to retrieve Unicode strings for non-ASCII data, but bytestrings for non-ASCII text: con.text_factory = sqlite.OptimizedUnicode or something custom: con.text_factory = lambda x: unicode(x, "utf-8", "ignore") Highly optimized row_factory for column access by name == A new function has been implemented that allows for case-insensitive column access by name with minimal performance and memory impact, unlike a dictionary or db_row-based approach. To enable it, set the row_factory attribute of your connection to sqlite.Row: from pysqlite2 import dbapi2 as sqlite con = sqlite.connect(...) con.row_factory = sqlite.Row cur = con.cursor() cur.execute("select name_last, age from people") for row in cur: print row["Name_Last"], row[1] Convenience methods === The execute(), executemany() and executescript() methods are now also available in the Connection class. This allows you to write very concise code like this: con = sqlite.connect(...) con.execute("insert into foo(bar) values (5)") for row in con.execute("select bar from foo"): print row API changes === The row_factory attribute has been moved from the Cursor class to the Connection class. For backwards compatibility, using it on the Cursor clas
Re: [ANN] pysqlite 2.1.0 released
Alex Martelli wrote: > Gerhard Häring <[EMAIL PROTECTED]> wrote: >... > >>An optimized shortcut has been enabled to retrieve Unicode strings for >>non-ASCII data, but bytestrings for non-ASCII text: >> >>con.text_factory = sqlite.OptimizedUnicode > > > I assume you mean "ASCII text" rather than "non-ASCII text" here? You're right. I stole this idea from APSW, another SQLite wrapper, which does this by default in order to reduce memory usage and increase performance a little bit for the common use case of ASCII text. You might argue that that this is premature optimization, but things like this do make a difference if you process a lot of text. Using this feature should be pretty compatible to the default of always using Unicode, because `unicode` and `str` have pretty much the same interface. But I wasn't 100 % sure, so I kept the old pysqlite default of Unicode only and made the optimized case using OptimizedUnicode an option. > At any rate, my compliments for a new release (which looks great!) of a > most excellent module! Thanks :-) -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Decimal vs float
Kay Schluehr wrote: > I wonder why this expression works: > decimal.Decimal("5.5")**1024 > > Decimal("1.353299876254915295189966576E+758") The result is a Decimal type, which can have *very high* values. > but this one causes an error > > 5.5**1024 > > Traceback (most recent call last): > File "", line 1, in ? > OverflowError: (34, 'Result too large') Because the result is a float, which values are limited by your hardware (CPU). > Another quirk is the follwoing: > > decimal.Decimal(5.5) > > Traceback (most recent call last): > ... > TypeError: Cannot convert float to Decimal. First convert the float to > a string > > If Mr. interpreter is as slick as he is why doesn't he convert the > float by himself? This is at most a warning caused by possible rounding > errors of float. floating points are always imprecise, so you wouldn't want them as an input parameter for a precise Decimal type. Because if your nice Decimal type would then look like this: Decimal("5.499") you would complain too, right? For more enlightenment, you can start with the PEP http://www.python.org/peps/pep-0327.html#explicit-construction > Instead of dealing with awkward wrappers, I wonder if literals > currently interpreted as floats could not be interpreted as Decimal > objects in future? No, because a software Decimal type is orders of magnitude slower than floating point types, for which there is hardware support by your CPU. If you're asking for additional Python decimal literals like mydecimal = 5.5d or whatever, that's a different question. I don't know if anything like this is planned. FWIW I don't think it's necessary. using the Decimal constructor is explicit too and we don't really need syntactic sugar for decimal literals. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python.org website ?
Tim Parkin wrote: > Fredrik Lundh wrote: > > >>>Good and congratulations, it shows that the source code is well >>>formatted/consistent - I wish the rest of the website html/data were so. >>>If you are suggesting that your skills can do this with the rest of the >>>site content then please, please help!! >>> >>>In fact I will ask you now, publicly, if you are willing to offer your >>>services to help convert the documentation and exsiting content over to >>>the new website? >>> >>> >> >>to what target environment? a wiki? sure. the current homebrewn solution? >>probably not; way too much new technology to learn, and absolutely nothing >>that I'm likely to end up using in any other context. >> >> > > OK... Sorry to break into this, but it seems there is not so much disagreement after all. I agree with /F that through-the-web editing would make it more likely to get more people on board and get the conversion done in time. Plus it would make maintanance easier once the beta from beta.python.org has been removed. If I see this correctly, Fredrik would volonteer to (help) implement something that imports the current python.org content into a Wiki. FWIW, I myself am also willing to contribute. MoinMoin 1.5 sounds perfect for the wiki. It supports ReST if we want that, and now also a JavaScript-GUI based WYSIWYG editor. If we agree that it's worth changing the primary data source from files to a Wiki, then either the current toolchain "pyramid" needs to be adjusted or a replacment needs to be written. I reckon all that's left to the building process is filling one or more templates with the content from the Wiki, and filling in the navigation links. Which is the main point of pyramid, I suppose? -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling cx_Oracle and LD_LIBRARY_PATH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Brian Cole wrote: > I can compile and install cx_Oracle fine by following the manta: > export ORACLE_HOME=... > python setup.py install > export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH > python > import cx_Oracle > > > My issue is the LD_LIBRARY_PATH. Is there a way to compile cx_Oracle, > or any Python extension for that matter so that it's not required to > set LD_LIBRARY_PATH? Is there a way I can make distutils do this for > me? Set runtime_library_dirs to a list of library directories you want to search at runtime in your setup.py. Check http://cvs.sourceforge.net/viewcvs.py/pypgsql/pypgsql/setup.py?rev=1.25&view=auto for an example. HTH, - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD0rQ5dIO4ozGCH14RAguJAJ9KW7g9pTP/co63Jn5DNF+GN4IMvgCeOYic a3yQm+oOdsiepvICBLQFt2A= =KeLY -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python.org website ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve Holden wrote: > Tim Golden wrote: > >>[Steve Holden] >> >>| https://svn.python.org/www/trunk/beta.python.org >> >>| but I don't know whether anonymous access is enabled. Maybe you can >>let >> |me know ... >> >>Doesn't look like it. Asking me for authentication. >> I've finally gotten to install pyramid and build the very small and outdated subset of the beta pydotorg site. Obviously, I'd like to have access to the "real" data in the python.org SVN. > Rats, thanks for letting me know. As a first step I'd like to open up > anonymous access to both the content and the site generation software, > so that people can experiment with local content generation. > > Then once someone knows how to use the system they can get a login for > the SVN system and start editing site content. > > I'll get back to the list with instructions ASAP. It may take a while > due to inter-continental time differences and general overwork. Are you still on it? I'd be happy enough with any kind of readonly access for myself for now. Thanks, - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD0skhdIO4ozGCH14RArdeAKCvolij/RdlCR+2f95usNaMAU5GKgCeOW2U 2OuazmveIIuaTpgJNSh4xOc= =IgFW -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python.org website ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tim Parkin wrote: > [...] Thanks for installing pyramid! Can > you give me any feedback on what parts of the install process were > painful.. There was nothing particularly painful. I tried to avoid having to install everything manually and to use the packages that my system (Ubuntu 5.10) provides where possible. In the end, this were only the Zope Interfaces and Twisted. Everything else was either in too old versions in Ubuntu or not packaged. - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD06YldIO4ozGCH14RAkJzAJ9SXjcDRnUIdkAVQIGCWiJyWKZHVwCgpsj6 irzdJP0rSR+IE81f5cAGkTU= =u3i0 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: New Python.org website ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've also done some experimentation this weekend, and my solution would be based on MoinMoin and KID. Fredrik Lundh wrote: > [...] and a more > extensive (but still rough) translation is available here: > > http://effbot.org/pydotorg/ > > the sample site contains ~600 pages. each page has been automatically > translated from python.org sources to moinmoin markup, and then stored > in a moinmoin 1.5 instance. a separate component has then extracted the > pages from moinmoin, and converted them XHTML fragments for rendering. Great. This sounds a lot like the ugly hacked script I produced that would dump all MoinMoin contents to XHTML in one directory, and the raw MoinMoin sources to another directory: http://ghaering.de/pydotorg/dumpwiki.py > (the sample pages on that page are basically the XHTML fragments as is; > the final site generator should of course use a suitable templating system > and nice CSS for the final product). [...] The other part of my experiment was a stupid build system that recursively looks for KID files in a directory tree and renders them to HTML. My idea is that for each KID file there would be a corresponding content.xml file that would come from the MoinMoin dump-to-XHTML (*). As for the navigation, my solution would look like this: - each KID file uses a master KID template - the "normal" KID files do look about like this: http://purl.org/kid/ns#";> The page title i. e. all they do is define the page title, and include the content XML file created from MoinMoin. - the "make-like" generator script will give each template its name as a parameter, so that the template (and in particular the master template) know what the current path is. Using this information, it can render the left-side navigation bar appropriately. - If there really is a need to, additional processing instructions can be put as comments in MoinMoin at the top of a wiki page, like: ## RENDER hideNav("/dev"); expandNav("/about") As we also have access to the dumped raw MoinMoin sources, we could parse these comments and handle them while rendering the KID templates. IMO this system would be flexible enough to do all that the current one can do, and integrate nicely with MoinMoin. It would be not *ALL* dynamic via MoinMoin, but at least the contents can be editied through a Wiki. Site structure would still be editied via the filesystem. What do you think of an approach like this? - -- Gerhard (*) MoinMoin dumps do not always produce valid XHTML, so eventually I still need a cleanup step. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFD062EdIO4ozGCH14RAhoRAJ9pumD9LpKRohngbacHXSaub+zYtQCgmyHd m9cCT2pXdRRIX0Qg+qdgMDM= =hljf -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Using pysqlite2
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dennis Benzinger wrote: > [EMAIL PROTECTED] wrote: >> Is it possible to use this for sending triggers to a sqlite db?Could >> someone provide me with an example of how to do this please? >> Thanks > > Do you want to implement a trigger for a SQLite database in Python? > > That won't work. Triggers in SQLite can only contain UPDATE, INSERT, > DELETE and SELECT statements http://sqlite.org/lang_createtrigger.html>. Yes, but you can fake it. You can create a new SQL function using pysqlite's create_function, and then just call that function in the trigger. In that Python function from the trigger, you can then even access SQLite again. I've attached a quick-and-dirty example. Note that exceptions in functions get ignored currently, so you better implement a try-except with some kind of logging during development, otherwise you will wonder why nothing happens. Also, older pysqlite releases won't provide useful error messages if you have errors in the SQL you send to executescript(). Using a recent pysqlite release is recommended if you plan to use executescript(). - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEgMQrdIO4ozGCH14RArFaAKCU8lgwidMoNQ0GGKVwJ2GV9xPF8ACfTDhv QVHvudLfoDGiIyFgHe5w6L4= =bfUa -END PGP SIGNATURE- from pysqlite2 import dbapi2 as sqlite def duplicate(col1, col2): cur = con.cursor() cur.execute("insert into test2(col1, col2) values (?, ?)", (col1, col2)) con = sqlite.connect(":memory:") con.create_function("duplicate", 2, duplicate) cur = con.cursor() cur.executescript(""" create table test(col1, col2); create table test2(col1, col2); create trigger my_trigger after insert on test for each statement begin select duplicate(new.col1, new.col2); end; """) cur.executemany("insert into test(col1, col2) values (?, ?)", [(x, x+1) for x in range(5, 8)]) con.commit() cur.execute("select col1, col2 from test2") print cur.fetchall() -- http://mail.python.org/mailman/listinfo/python-list
[ANNOUNCE] pyPgSQL 2.5 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, the last pyPgSQL release was in July 2003. Now, after a much too long time I went through all items in the bugtracker and created a release. pyPgSQL is a Python database adapter for PostgreSQL databases. Its homepage is at http://pypgsql.sf.net/. Downloads are available here: http://sourceforge.net/project/showfiles.php?group_id=16528&package_id=20458&release_id=421992 There is a source package and Windows binaries for Python 2.4. The Windows binaries are dynamically linked this time, so you will need a PostgreSQL client library installation to make sure the DLLs are found. It's probably easiest to just include the PostgreSQL bin and lib directory in your PATH. Attached is a ChangeLog. - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEgNkXdIO4ozGCH14RAgqlAJ9nNNGM1cTzMK804tV3ItOlDBcuBQCfYvQR GFaIhZnChH8ORdW7qMHKJMA= =K3Y4 -END PGP SIGNATURE- Announce: pyPgSQL - Version 2.5 is released. === pyPgSQL v2.5 has been released. It is available at http://pypgsql.sourceforge.net. pyPgSQL is a package of two (2) modules that provide a Python DB-API 2.0 compliant interface to PostgreSQL databases. The first module, libpq, is written in C and exports the PostgreSQL C API to Python. The second module, PgSQL, provides the DB-API 2.0 compliant interface and support for various PostgreSQL data types, such as INT8, NUMERIC, MONEY, BOOL, ARRAYS, etc. This module is written in Python and works with PostgreSQL 7.0 or later and Python 2.0 or later. It was tested with PostgreSQL 8.1.4 and the latest patchlevels of Python 2.1, 2.2, 2.3 and 2.4. Note: It is highly recommended that you use PostgreSQL 7.2 or later and Python 2.1 or later. If you want to use PostgreSQL Large Objects under Python 2.2.x, you *must* use Python 2.2.2, or later because of a bug in earlier 2.2 versions. Project homepages: pyPgSQL:http://pypgsql.sourceforge.net/ PostgreSQL: http://www.postgresql.org/ Python: http://www.python.org/ --- ChangeLog: === Changes since pyPgSQL Version 2.4 = Changes to README - * Updates for 2.5. Changes to PgSQL.py --- * Additional attribute cursor.debug: Setting this attribute to 'text' will cause the query that will be executed to be displayed to STDOUT. If it is set to 'pre' or 'div', the query will be displayed to STDOUT within a or HTML block. If it is set to None (the default), the query will not be displayed. * New module-level variable useUTCtimeValue: Setting this variable to 1 will cause the datatime instance returned from the result set for a timestame with timezone to reference the corresponding UTC time value (not the value expressed in the clients time zone). * mxDateTime's RelativeDateTime instead of DateTimeDelta is now used for PostgreSQL INTERVALs. * Several other fixes in the PostgreSQL interval code * Several bugfixes in the PgNumeric type * PgInt2 and PgInt8 used to be custom number types that checked for overflows in their specific ranges. In order to make them work across current Python versions we got rid of them and replaced them with int and long. * Many changes in parameter quoting to make them work in more cases like * PostgreSQL procedures Changes to libpqmodule.c * Bugfix for quoting Bytea types Changes to pgconnection.c - * Fixed compatibility problems with PostgreSQL 8.x. * Added debug support Changes to pgresult.c - * Integrated patch #1224272. Use PyOS_ascii_strtod instead of strtod in order to be locale-agnostic. Changes to pgversion.c -- * Applied patch #882032. Vendor-extensions to version number should not create problems any longer. * Fixed Bug #786712 & #816729: Allowed for a version string containing the words "alpha" and "beta". -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.3.0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 pysqlite 2.3.0 released === I'm pleased to announce the availability of pysqlite 2.3.0. This is a major release with a few new features. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. pysqlite can be downloaded from http://pysqlite.org/ - Sources and Windows binaries for Python 2.4 are available. Windwos binaries for Python 2.3 will follow during the next days. === CHANGES === "Errors should never pass silently." Errors in callbacks used to simply be ignored. They would lead to the column in question having a NULL value, for example. Now they result in the query being aborted with a useful error message like "User-defined function raised exception". Errors in callbacks can now be printed to stderr. You have to enable this feature first by calling enable_callback_tracebacks(1), though. Aborting long-running queries = You can now interrupt queries by calling interrupt() on the connection (from a different thread) Now with built-in paranoia == There is a new connection-level method set_authorizer() for adding authorizer hooks. You can use it to accept arbitrary SQL statements from users and limiting what they can do with the database, for example only allow SELECT statements and restricting access to certain tables or columns. Changes for converters == Converters are now looked up in a case-insensitive manner. Bugfixes Fixed a bug where it was possible that one error while constructing a result row was hidden by another error. This resulted in segmentation faults. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEjwmCdIO4ozGCH14RAtUAAJ9UpQFdcPhqEvQEdPWNJUaP2LtoagCcC8Hu JhIIha/vNIOpahH+pNMOZzo= =VpsE -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: [pysqlite] [ANN] pysqlite 2.3.0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dawid Gajownik wrote: > Dnia 06/13/2006 08:52 PM, Użytkownik Gerhard Häring napisał: > >> pysqlite 2.3.0 released > > Great :) I have one more problem, though. It does not compile: [...] > src/connection.c:31:26: error: sqlitecompat.h: No such file or directory > [...] > I had to manually download this file [sqlitecompat.h] > Why it's not included in the tarball? python setup.py sdist didn't recreate the MANIFEST file, so it was omitted. I've uploaded a fixed source tarball now. It's my fault, I should have tried to build from the source tarball, like I normally do before a release ... - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEjxShdIO4ozGCH14RAuodAJ9N5bbR5lBtdWjzk2xMMivATIi63wCgoHNP y77XMzv1kmP9kIMFc3yQCSI= =VdBx -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: [pysqlite] memory-leak in pysqlite 2.3.0 ?
Michael Husmann wrote: >> Michael Husmann wrote: >>> After upgrading from pysqlite 2.0.5 to pysqlite 2.3.0 writing into a >>> sqlite database increases memory consumption heavily. A similar program >>> with Ruby and sqlite-ruby 1.1.0 does not affect memory consumption at >>> all. >>> [...] >>> Python 2.4.1, Sqlite3 3.3.6, Pysqlite 2.3.0 >> You never COMMIT your changes here, that's probably what's causing >> memory consumption on the SQLite side of things. >> [...] > > I also tried that commit(). Memory consumption still grows permanently. Thanks for the report. Upon debugging this a little, there's indeed a bug which crept in in pysqlite 2.2.1 because of incorrect usage of the weak references (*). This leads to the list of weak references per connection to always grow and never shrink. I'll try to provide a fix real soon. -- Gerhard (*) A missing PyWeakref_GetObject(), but I'll have to take a more careful look. -- http://mail.python.org/mailman/listinfo/python-list
Re: [pysqlite] memory-leak in pysqlite 2.3.0 ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gerhard Häring wrote: > Michael Husmann wrote: >>> Michael Husmann wrote: >>>> After upgrading from pysqlite 2.0.5 to pysqlite 2.3.0 writing into a >>>> sqlite database increases memory consumption heavily. A similar program >>>> with Ruby and sqlite-ruby 1.1.0 does not affect memory consumption at >>>> all. >>>> [...] >>>> Python 2.4.1, Sqlite3 3.3.6, Pysqlite 2.3.0 >>> You never COMMIT your changes here, that's probably what's causing >>> memory consumption on the SQLite side of things. >>> [...] >> I also tried that commit(). Memory consumption still grows permanently. > > Thanks for the report. Upon debugging this a little, there's indeed a > bug which crept in in pysqlite 2.2.1 because of incorrect usage of the > weak references (*). This leads to the list of weak references per > connection to always grow and never shrink. I'll try to provide a fix > real soon. > > -- Gerhard > > (*) A missing PyWeakref_GetObject(), but I'll have to take a more > careful look. Fixed in Subversion. A pysqlite 2.3.1 release will follow during the next days, which is the same code that will be in Python 2.5 beta1 btw. - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFElxUfdIO4ozGCH14RAlk4AJ9JMMkGTdwJ5moM1/7FDFBP/XFZdACghOuj 2FNxgi7F7R+V6ARtzXgyNDY= =29Gx -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: any subway web dev experiences
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Fredrik Lundh wrote: > bruno at modulix wrote: > >> Nope - it's a Python MVC web framework. Like Django, Pylons and >> Turborgears. And FWIW, there have been recently some discussions about >> merging Subway and Turbogears. > > recently? was that before or after the developer picked up his marbles > and went home to complain to his mother? So it was not only me that found this behaviour especially childish ... > (according to the subway wiki, only porn sites use the framework these > days. hint to developers: if you're shutting down a project, make sure > you lock down the project site). Unfortunately, this not only applies to shut down projects, but also to alive projects using Trac. It's a failure of Trac, because their developers don't see spam as such a big problem to warrant implement basic antispam support now instead of in a future release. Instead of diving deeper into Trac or installing the antispam version of it that is developed as a branch in their sandbox or otherwise wasting a lot of time, I tried to solve the problem the pragmatic way by installing a cron job that periodically runs the following commands on the SQLite database: [EMAIL PROTECTED]:~$ cat delspam.sql delete from wiki where text like '%cialis%'; delete from wiki where text like '%plumper%'; No spam was seen since then on the pysqlite wiki ... - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFElxlBdIO4ozGCH14RAtMPAJ45eFuVwV+EMVWITDulxuex0R9gtgCgjKfn 5L1NQjaBOgZEJARVq6Y+2mU= =eZkz -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.3.1 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 pysqlite 2.3.1 released === I'm pleased to announce the availability of pysqlite 2.3.1. This is a bugfix release, but it includes important fixes. Users of pysqlite 2.2.1 to 2.3.0 should definitely upgrade. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. pysqlite can be downloaded from http://pysqlite.org/ - Sources and Windows binaries for Python 2.4 and Python 2.3 are available. === CHANGES === - - Implemented a workaround for SQLite versions < 3.3.3: they are buggy and cannot use sqlite3_result_error from certain callbacks. So we cannot abort queries from callbacks. For these SQLite versions we set the Python exception and catch it later on when sqlite3_step is finished. - - Plugged a memory leak that affects pysqlite versions 2.2.1, 2.2.2 and 2.3.0: due to wrong usage of weak references, an internal list of weak references was always growing with each new statement text executed on the same connection. - - Removed a call to enable_callback_tracebacks that slipped in the test suite. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEmG+qdIO4ozGCH14RAhP1AKC28KMKzup8JuBnAnXSXwG7BdZzvgCfYDMm 5aCJ/bhuAZLCRFK7Nauj9Gs= =7o3U -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: connect not possible to Oracle Datenbank as sysdba?
Cihal Josef wrote: > Hi, > > how can I connect to oracle database as SYSDBA > > as usually: "sqlplus anc/psw as sysdba" > > It is a parsing problem? (blanks,etc.?) > > or it is not implmented in DCOracle2? [...] From a quick glance at the code, it does not seem like it is implemented in DCOracle2, which had its latest stable release as "1.3 beta" at 2003-02-10 14:47:59. You should consider switching to cx_Oracle, which is much better maintained and also allows you to connect as sysdba: import cx_Oracle con = cx_Oracle.connect("sys", "topsecret", "my_tns", cx_Oracle.SYSDBA) HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Kay Schluehr wrote: > [EMAIL PROTECTED] wrote: > >> I wouldn't be at all surprised if the pysqlite author operated under that >> assumption. That the Python developers didn't pick up on the issue is not >> surprising. I'm not sure how many of them are (py)sqlite users, probably >> relatively few. >> >> Skip > > Who has reviewed sqlite/pysqlite after all? pysqlite was actually reviewed by several Python core developers before becoming a part of the Python standard library, most prominently Neil Norwitz and Anthony Baxter. > Reading the passage in the > sqlite FAQ I can hardly believe that passing errors silently and > coercing everything to string when it fails to be coerced to INTEGER > although INTEGER was an invariant declared in the create command is on > par with Pythons design philosophy. [...] Unfortunately, third-party library authors don't first check with Python's design philosophy in case their software will be wrapped as a Python module ;-) I did my best to combine both SQLite's and Python's type system though, including a discussion with pysqlite 1.x users before the grand rewrite for version 2, which is the one that ended up in the Python standard library now. > In other cases doctoral dissertations are written about whether a > keyword or some punctuation shall be used for decorator syntax and in > this case everything must be rushed into the code base of the > standard library? There was no rush at all. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] markup.py 1.5 - a lightweight HTML/XML generator
Daniel Nogradi wrote: > A new release of markup.py is available at > > http://markup.sourceforge.net/ > > The markup module is an intuitive, lightweight, easy-to-use, > customizable and pythonic HTML/XML generator. [...] It's more than only a bit confusing that there's also Markup: A toolkit for stream-based generation of markup for the web at http://markup.edgewall.org/ - basically a replacement for the Kid XHTML templating solution. At first I was confusing your project with the other package, which I was planning to give a try sooner or later. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Backreferences in python ?
Pankaj wrote: > [...] > > What i tried in python was:: > > > f = open( "./1.c", "r") > fNew = open( "./1_new.c", "w") > for l in f: > print l > lineno = lineno + 1 > strToFind = "for\((.*)\;(.*)" > [...] Regular expressions are not handled automatically in Python the way you apparently think they are. In Python, you will need to use the "re" module: http://docs.python.org/lib/module-re.html -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: How to enable rotor in python 2.4.2?
Murphy Wong wrote: > Dear all, > > I've installed python 2.4.2 and Zope 2.8.5 on a 64-bit Linux. As I'm > installing FLE (http://fle3.uiah.fi/), I find that it will call the > rotor module i npython. However, rotor is removed from python 2.4.2 > (http://savannah.nongnu.org/bugs/?func=detailitem&item_id=14434). Could > I enable rotor some ways in python again? Thanks. You could get the module from some older Python version (http://svn.python.org/projects/python/branches/release23-maint/Modules/rotormodule.c) and compile it for Python 2.4. You need a C compiler and a minimal setup.py file for compiling the module: from distutils.core import setup from distutils.extension import Extension setup ( name = "rotor", ext_modules = [Extension( name="rotor", sources=["rotormodule.c"] )] ) HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary inserts into MySQL (each key in its own field)
Derick van Niekerk wrote: > [quote] > d = {"spam": "1", "egg": "2"} > > cols = d.keys() > vals = d.values() > > stmt = "INSERT INTO table (%s) VALUES(%s)" % ( > ",".join(cols), ",".join(["?"]*len(vals)) > ) > > cursor.execute(stmt, tuple(vals)) > [/quote] > > I will be using the python-mysql API. This looks like what I am looking > for. I just have a question about the last join statment. In this case > it would just create a string = '?,?' - wouldn't it? Other than that, > it is pretty easy to understand. Now - how do I escape the string for > characters that might break the script e.g. [' " \ ) ( ...]? [...] You don't need to escape the strings, because the example code uses the parametrized form of the cursor.execute statement, and the DB-API module will just do the right thing. The example code will maybe not work like this, because IIRC MySQLdb uses paramstyle = "format", and not paramstyle = "qmark". I. e. you will have to use %s as placeholders in the query, and not ?. So you would have to replace the ",".join(["?"]*len(vals)) with ",".join(["%s"]*len(vals)). -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: "Python Drive Name" is the search, what is the question?
Gregory Piñero wrote: > Just thought I'd see if you guys had an answer for this. My website > analytics page shows that people come to my site after searching for > "Python drive name" but I don't think I'm offering any help with such > a thing. > > However I would like to help since I'm getting a few people a day for > this. So does anyone have an idea on what they could be searching for > and of course what the answer would be? > > Sorry it's such a vague question for you guys, but I thought maybe > you'd enjoy a mystery for the day! Maybe which drive Python is installed on? >>> os.path.splitdrive(sys.prefix)[0] 'c:' No I can't really guess what these people are looking for ... -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Issues installing MySQL-python-0.3.5
Sorry for the duplicate email, Keith. [EMAIL PROTECTED] wrote: > Hi, > > I am trying to use the Python MySQL APIs and have been attempting to > install the above software. > > I am using MySQL 5.0.18-standard with Python 2.4.1 > > I get errors on the build. Some searching showed that one of the modules > I was having issues with now has less arguments in my version of python, > but I can't seem to fix the following error: > > *** > _mysqlmodule.c: In function ‘_mysql_ConnectionObject_shutdown’: > _mysqlmodule.c:1019: error: too few arguments to function > ‘mysql_shutdown’ > *** > Should I just give up on MySQL-python-0.3.5 ? [...] This release is almost 5 years old. Where did you dig it out from? ;-) http://dustman.net/andy/python/MySQLdb_obsolete/0.3.5 """ MySQLdb module 0.3.5 OBSOLETE Python Interface to MySQL Stability: Perfect in every way Released: 2001-03-25 00:00 UTC Notes NOTICE: This version works fine, but I strongly recommend 0.9.0 or newer, available from SourceForge. """ I'd try MySQLdb 1.2.0, which *might* work, according to its README: """ * MySQL-5.0 and newer are not currently supported, but might work. * MaxDB, formerly known as SAP DB (and maybe Adabas D?), is a completely different animal. Use the sapdb.sql module that comes with MaxDB. """ -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Clarity: GIL, processes and CPUs etc
[EMAIL PROTECTED] wrote: > I have been reading many of the posting on the GIL and impact on > threading etc. I have found is confusing and would welcome some > clarity on this. > > I understand that embedding the interpreter in a C/C++ application > limits it to one CPU. If the application is multi-threaded (system > threads) in will not use additional CPUs as the interpreter is tied > to one CPU courtesy of the GIL. True or False? True. More than one CPU can be used if the GIL is released during calls to external libraries, though. Well-written C extension modules and the Python standard library do this where appropriate. Still only one thread can execute pure Python code at a time. > I understand that forking or running multiple process instances of the > above application would make use of multiple CPUs. This is because each > process would have its own interpreter and GIL that is independent of > any other process. > True or False? [...] True. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Oracle Interace on Solaris
[EMAIL PROTECTED] wrote: > I am trying to use Python to do queries on a Oracle database using a > Solaris box. I have seen tools such as cx_Oracle which would be good > except that my Solaris box does not have an Oracle installation. Do I > need to have an Oracle installation on my Solaris box to access the > Oracle database (which is on another machine)? Are there ways to access > an Oracle database and do queries without having a local copy of Oracle > installed? Thanks. There is, but only using Jython, Java and using Oracle's "thin" pure-Java JDBC client library. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: converting sqlite return values
bolly wrote: > Hi, > I've been putting Python data into a sqlite3 database as tuples but > when I retrieve them they come back as unicode data e.g > 'u(1,2,3,4)'. Looks like you're using pysqlite 2.x. > How can I change it back to a tuple so I can use it as a > Python native datatype? You cannot store tuples using pysqlite directly: >>> from pysqlite2 import dbapi2 as sqlite >>> con = sqlite.connect(":memory:") >>> cur = con.cursor() >>> cur.execute("create table test(foo)") >>> t = (3, 4, 5) >>> cur.execute("insert into test(foo) values (?)", (t,)) Traceback (most recent call last): File "", line 1, in ? pysqlite2.dbapi2.InterfaceError: Error binding parameter 0 - probably unsupported type. >>> That's because only a limited set of types that have a sensible mapping to SQLite's supported data types is supported. So probably you did something like: >>> cur.execute("insert into test(foo) values (?)", (str(t),)) >>> cur.execute("select foo from test") >>> res = cur.fetchone()[0] >>> res u'(3, 4, 5)' >>> Aha. You stored a string and got back a Unicode string. That's all ok because SQLite strings are by definition all UTF-8 encoded that's why the pysqlite developer decided that what you get back in Python are Unicode strings. Now there are different possibilites to attack this problem. a) Use SQLite as a relational database and don't throw arbitrary objects at it b) Write a custom converter and adapter for your tuple type. See http://initd.org/pub/software/pysqlite/doc/usage-guide.html#sqlite-and-python-types This way it will all work transparently from you once you've done the preparations. c) Store and retrieve the whole thing as a BLOB and convert manually: >>> cur.execute("delete from test") >>> cur.execute("insert into test(foo) values (?)", (buffer(str(t)),)) >>> cur.execute("select foo from test") >>> res = cur.fetchone()[0] >>> res >>> eval(str(res)) (3, 4, 5) That's the simple apprach, but it sucks because eval() is sloppy programming IMO. So I'd rather marshal and demarshal the tuple: >>> import marshal >>> cur.execute("delete from test") >>> cur.execute("insert into test(foo) values (?)", (buffer(marshal.dumps(t)),)) >>> cur.execute("select foo from test") >>> res = cur.fetchone()[0] >>> marshal.loads(res) (3, 4, 5) > I have looked in the docs and seen there is a decode/encode method but > how do I do this? You don't. This was for only there in pysqlite 1.x and pysqlite 2.x. In pysqlite 2.x, you use the Python builtin buffer() callable to convert strings to buffers to mark them as BLOB values for pysqlite and you willg et back buffer objects from pysqlite for BLOB values, too. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Little tool - but very big size... :-(
Durumdara wrote: > Hi ! > > I have a problem. > I have a little tool that can get data about filesystems and wrote it in > python. > > The main user asked me a GUI for this software. > > This user is needed a portable program, so I create this kind of the > software with Py2Exe. > > But it have very big size: 11 MB... :-( [...] You can create an installer using NSIS and choose LZMA compression. That's the slickest way I know to distribute your application. If that's too much trouble, you can also distribute your application as a self-extracting 7ZIP-Archive using LZMA compression (http://www.7-zip.org/). Quick size test here with a small wxPython helper app of mine: py2exe dist directory size: 12.469.572 Bytes 7ZIP self-extracting archive (LZMA, default settings): 2,80 MB (2.942.543 Bytes) A NSIS installer will not add much overhead (a few hundred KB). HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Little tool - but very big size... :-(
Durumdara wrote: > Hi ! > > Yes, it is. But that tool is designed for USB PenDrive usage. > The assessor is collect all tools it needed to see a machine(s) in the > checked corporation. > He/she needs little programs, because he need to store the results of > the checkings too, not the tools only. [...] Additional Python or wxPython tools packed using py2exe will only need a few kilobytes if you all copy them to the same directory on the pen drive. All these tools can share the same .pyd and .dll files. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: CGI and Redirect
Grzegorz Ślusarek wrote: > Hi All. I need to redirect user in my CGI script, i Try to use prin > "Location: "+url but this is not working. Can anyone tell me what I'm > doing wrong? > Any thanks will be apreciated I guess you forgot to set the HTTP-Status. Either: print "Status: 301" # Moved Permanently or print "Status: 302" # Moved Temporarily HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Little tool - but very big size... :-(
Max wrote: > Giovanni Bajo wrote: > >>There are also other choices that can be made. For instance, wxWidgets is >>*HUGE*. > > Indeed. Remember Tkinter is built-in. [...] Tkinter is only built-in in the sense that it's shipped with Python by default. It is not automatically part of a minimal Python runtime that's created with py2exe or a similar tool. A Tkinter hello weights here 1,95 MB (2.049.264 Bytes) compared to the small wxPython tool that I compressed recently: 2,80 MB (2.942.543 Bytes) All self-extracting LZMA compressed archives using 7ZIP. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: cx_Oracle and UTF8
Harald Armin Massa wrote: > Dietz, > > thank you for your answer. > >>It's called NLS (national language support), >>and it is like a locale-setting in python/C. I'm too lazy to google right > > Sad thing: I allready googled that and had to learn: you CAN definitely > change some parameters, that is sort order and language for error > messages with > alter session set NLSREGION and set NLSLANGUAGE > > The only part about the charset is with NLSLANG, which could be set to > German_Germany.UTF8 > > BUT ... NLSLANG is no per-session parameter, not setable per alter > session, it needs to get set within the environment to make SQLPLUS > recognize it. (and, I do of course use python not sqlplus= [...] This is handled by the OCI, which both your Pyhton interface and SQLPLUS use. You should be able to do something like: import os os.environ["NLS_LANG"] = "German_Germany.UTF8" import cx_Oracle con = cx_Oracle.connect("me/[EMAIL PROTECTED]") cur = con.cursor() cur.execute("select foo from bar") print cur.fetchone()[0] HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb slow on MySQL 5
[EMAIL PROTECTED] wrote: > Hi. > > I have a Python program that parses a file and inserts records into a > database with MySQLdb. I recently upgraded to MySQL 5.0.8, and now my > parser runs *really* slow. Writing out to CSV files is fine, but when I > try to insert the same records in a MySQL5 database, it slows to a > crawl. Using MySQL 4.1 seems fine. The data seems to be inserted > correctly, it's just really slow. > > Has anyone else noticed a similar problem using MySQL5 and MySQLdb? Maybe you're running in autocommit mode. I. e. an implicit COMMIT is done for each insert. This slows any database down. Or are you calling commit() yourself too often? -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQLdb slow on MySQL 5
Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > > I'm not calling COMMIT at all. > > Then you must be using autocommit if your records stay in > the table. An DB-API 2.0 compliant adapter should turn off > autocommit by default! Does MyISAM even support proper > commit handling? [...] No, it doesn't. And COMMIT is then simply a no-op if it doesn't raise an error already. > Oh well, Oracle will probably kill MySQL soon. Did you read too much Slashdot to spread such FUD? > [...] I'd use a real database system. MySQL 5 could be described as one, according to the feature list, and if you use a transactional table type. I myself won't bother with it because PostgreSQL is still more featureful that MySQL 5, has a much longer track record with these features proven stable and a more liberal licensing. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [EMAIL PROTECTED] wrote: > What would be the next best Oracle database module for Python next to > cx_oracle? That would probably be DCOracle2. > I'd like to compare two and choose one, just for the sake of > seeing how two modules doing the same thing operate. > > Also, does installing cx_oracle create registry entries or require > admin privs on a Windows XP machine? I see that cx_oracle is > distributed as an EXE. It's most probably created using distutils and "python setup.py bdist_wininst". These installers only use the registry to look up the path Python where is installed. Of course it will need a correctly working Oracle client to operate. - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEBJxBdIO4ozGCH14RAqXCAJ9Vq6L8SLvnhlBCDc4EzwloJYp28ACfVt8J TNN+XgNxFLmQscu9wpPIK4M= =txAA -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: ODBC module and strange date reference <...>
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > >>Been using the ODBC module for Python 2.1 > > > It might well become a problem that you are stuck with > a five year old Python version. Python 2.1 is no longer > a supported Python version. Support for 2.2 will probably > end soon. [...] At this point you shouldn't expect anything but the Python 2.4 series to be actually supported. By supported I mean that a new minor release will happen if a significant bug is found. - -- Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFECItwdIO4ozGCH14RApVHAJ4ieo901ys5ygcKedSNaNCSpPjbqgCfZKSV uRakdde/S8erdk1RnMJIiI0= =YgSZ -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python & SQLite
dcrespo wrote: >>There are specific python modules for SQLite on Linux. > > Which? I thought pysqlite works on Linux. Sure. What he probably meant was that there are binary installers for pysqlite from various Linux distributions (Debian, Gentoo, ...). > My important question is: If I develop an app using > Python-wxPython-PySQLite under Windows, and run it on Linux, it should > work, ¿right? Correct for Python and pysqlite. For wxPython you will often have to do fine-tuning because some bugs are only present on Windows, and some bugs are only present on *nix. And things sometimes look slightly different. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are -1 supplied.
F. GEIGER wrote: > Arrgh, sorry for that post! > > self._dbc.execute(q, data) > > where data is None, works with MySQL. For SQLite I have to write > > if data is not None: > self._dbc.execute(q, data) > else: > self._dbc.execute(q) No, you have to write: self._dbc.execute(q, (data,)) in both drivers. i. e. the second parameter to execute *must* be a sequence. Some drivers (maybe MySQLdb, too) automatically correct the wrong call and transform a: execute(sql, single_param) into a execute(sql, (single_param,)) for you if they notice that "!PySequence_Check(single_param)". pysqlite 2 does not do this. HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: pysqlite - Checking the existance of a table
rh0dium wrote: > Hi all, > > I am starting to play with pysqlite, and would like to know if there is > a function to determine if a table exists or not. You can try to access the table in a try-catch block, something like: cur.execute("select * from tablename where 1=2") and check if it fails. Or you can query the sqlite_master table (don't know any specification off-hand, but it contains the schema information). Instead of doing a select on sqlite_master, you can use "pragma table_info", which returns information for each column in the table, and, apparently, an empty list if the table does not exist: >>> cur.execute("pragma table_info(foo)") >>> print cur.fetchall() [(0, u'bar', u'integer', 0, None, 0)] >>> cur.execute("pragma table_info(foo_does_not_exist)") >>> print cur.fetchall() [] HTH, -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.3.4 released
pysqlite 2.3.4 released === I'm pleased to announce the availability of pysqlite 2.3.4. This is a bugfix release. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. pysqlite can be downloaded from http://pysqlite.org/ - Sources and Windows binaries for Python 2.5, 2.4 and Python 2.3 are available. === CHANGES === - pysqlite is now easy_install-able. - Under some circumstances it's was not possible to close the connection object. This happened if you still had cursor objects around with statements that were no longer in the cached statements pool. This was fixed by finalizing all statements that were created from the connection instead of only those that are still found in the connection pool. - SQLite often does not report useful error messages when the stepped-on statement was not reset first. Now we make sure that's always the case. - From Python core version: Patch by Tim Delany (missing DECREF). SF #1731330. - Merged missing corrections for sample code from Python core version. - Allow the size parameter for fetchmany() for better DB-API compliance. - Allow a static build of pysqlite using the SQLite amalgamation. Copy sqlite3.c and sqlite3.h into the pysqlite directory, then use $ python extended_setup.py build_static to build pysqlite. setuptools must be installed in order to use the extended_setup.py script. - Applied patch from #184. This defers the implicit BEGINs/COMMITs and thus improves concurrency. - Print a warning if somebody tries to run the pysqlite test suite from the pysqlite root directory and exit. In earlier versions, the user would get a hard to understand error message about a missing extension module instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 bug??
Hyuga wrote: > On Jun 17, 9:16 am, mark carter <[EMAIL PROTECTED]> wrote: >> Should I also explicitly close the cursor and connection, or is that >> taken care of "automagically"? >> > > Somebody correct me if I'm wrong, but I'm pretty sure that the Cursor > and Connection objects properly clean themselves up when deallocated > (when their reference count reaches 0), so not explicitly closing them > isn't a terrible thing. [...] That's correct for pysqlite, and probably for all other DB-API modules too. If you have a client-server database, it's nicer to close the database connection if you don't need it any longer in order to free up resources on the server, of course. > In fact, I have code in which references to a db connection are > passed around, so I have to be careful about explicitly closing the > connection, lest it be in use by some other method somewhere. Maybe > people will frown on this, but it's not uncommon. I don't think I've ever explicitly closed a cursor object when programming to the DB-API myself. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite newbie question - how to know if a table exists?
[EMAIL PROTECTED] wrote: > Hello, > > Another newbie question: How do I know if there is a table with > certain name in a sqlite database? What i'm doing now is just create > the table with that name, if exception occurs, that means the table is > already created. Am i correct? Any better way? Thank you. That approach is ok. If your SQLite library is recent enough (I don't know the exact version), you can use "create table if not exists ...". For older SQLite releases, you can check like this: len(con.execute("pragma table_info(?)", ("tablename",)).fetchall()) > 0 or con.execute("select count(*) from sqlite_master where name=?", ("tablename" ,)).fetchone() -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: trouble with sqlite under debian etch
Rustom Mody wrote: > I was trying to follow the sqlalchemy tutorial on my debian etch box > and got stuck with installation. Any help/pointers will be welcome. > > First after installing sqlalchemy needed some sqlite package > synaptic showed me packages python-pysqlite, python-pysqlite1.1 and > python-pysqlite2. > [...] Or just use Python 2.5, which includes a "sqlite3" module that SQLAlchemy can use. > Theres some confusion regarding numbers: python-pysqlite2 is for > sqlite3 or some such thing the 2 in python-pysqlite2 is for > Tried python-pysqlite1.1 and got errors. Tried 2 and got version warnings. > > Downloaded the tgz and did a setup build followed by a setup install > > Now the db = create_engine('sqlite:///tutorial.db') > gives me no module _sqlite Did you execute that in the pysqlite root directory (i. e. the one that "setup.py" and friends are?). Unfortunately, any other working directory will be ok, but this one isn't. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTP server w/o using Twisted framework
_spitFIRE wrote: > [looking up DNS MX records] > Thanks for the pointer. However, as I said currently, I can't use > anything other than the standard libraries. Sure you can. You just need to get rid of the "only standard library" requirement rule. That works best by showing the alternatives to whoever set that requirement: - use pyDNS - use an existing (probably non-Python) SMTP daemon - reimplement some parts of pyDNS yourself and develop a basic (crappy) SMTP daemon yourself For doing the latter, you should budget at least one week. FWIW another reason why SMTP servers should retry on temporary failure is that increasing use of Greylisting (*), which was precisely designed to filter out mail from "crappy" servers, like botnets, and - well - cheap custom written ones ;-) -- Gerhard (*) http://en.wikipedia.org/wiki/Greylisting - I use it myself -- http://mail.python.org/mailman/listinfo/python-list
Re: Tests for Python Database API
MD wrote: > Are there any tests that will help me ensure that my Python database > driver conforms to the Database API v2.0 specification? There's this: http://www.initd.org/tracker/psycopg/browser/psycopg2/trunk/tests/dbapi20.py -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Per thread data
Will McGugan wrote: > Hi, > > Is there a canonical way of storing per-thread data in Python? Good question. There's threading.local() which creates a thread-local object for you. Maybe this Cookbook entry is helpful: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302088 -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: How to check if file is in use?
loial wrote: > Is there anyway in pythn to check whether a file is being used/written > to by another process, e.g like the fuser command? No, you'll have to use platform-specific methods (like calling fuser etc. with the subprocess module). -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.3.5 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 pysqlite 2.3.5 released === I'm pleased to announce the availability of pysqlite 2.3.5. This is a bugfix release. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. pysqlite can be downloaded from http://pysqlite.org/ - Sources and Windows binaries for Python 2.5, 2.4 and Python 2.3 are available. === CHANGES === Ticket #203: Using mappings and sequences as parameters works now too. I hope this doesn't encourage you to actually use that "feature". It's actually possible to build a layer on top of the DB-API instead of cramming everything into it. Ticket #97: We now know about implicit ROLLBACKs that the SQLite engine issued. Removed paragraph in docs about ON CONFLICT ROLLBACK not working. It works now. Performance optimizations that pay off especially for mass DML operations (inserts, updates, deletes). Performance here is on par with apsw now. See http://initd.org/tracker/pysqlite/wiki/PysqliteTwoBenchmarks for a benchmark of all pysqlite 2.x releases so far. Last two: pysqlite 2.3.4 average insert time: 7.037440 seconds average fetch time: 3.066811 seconds -- pysqlite 2.3.5 average insert time: 2.788332 seconds average fetch time: 3.095180 seconds -- - - A Python 2.3 compatibility fix in the test suite. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGnVGWdIO4ozGCH14RAkgQAKCTcumGWSTrQn+zK59kR2RUj29ZFACfcPVB 0WBUZOhw8ett2MPw+0qlPjw= =d+mW -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 db update extremely slow
coldpizza wrote: > Thanks a lot, Roel, adding a single commit() at the end did solve the > speed problem. > > Another question is do I have to explicitly close the DB connection, > or is it automatically garbage collected? Is it Ok to no have any > cleanup code? > > Another question would be how to define the encoding for newly added > records? > And how do set the encoding for the retrieved records? Is it always > utf-8 by default? SQLite databases store text in UTF-8 encoding. If you use pysqlite, and always use unicode strings, you will never have any problems with that. pysqlite does not rap on your knuckles if you store arbitrary encodings in the database, but you will feel sorry once you try to fetch the data: >>> from pysqlite2 import dbapi2 as sqlite >>> con = sqlite.connect(":memory:") >>> binary_rubbish = chr(130) + chr(200) >>> con.execute("create table foo(bar)") >>> con.execute("insert into foo(bar) values (?)", (binary_rubbish,)) >>> # so far, so good ... ... # watch now ... >>> con.execute("select bar from foo") Traceback (most recent call last): File "", line 1, in pysqlite2.dbapi2.OperationalError: Could not decode to UTF-8 column 'bar' with text '��' >>> HTH -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: Compatibility of python2.5 with pytohn2.3
VISHAL KANAUJIA wrote: > Hi all, > I am new member of this post. I have a C application which uses > Python(version 2.3) extensively with SWIG wrappers. I want to upgrade > the Python to latest version2.5. > > Is there any compatibility issue between two versions? Does latest > Python2.5 provide backward compatibility to previous Python (Version > 2.3 in my case) constructs. Short answer: yes. I've never had any issues here (compiling Python extension code in newer Python versions). The other way around that's of course not the case. I have to test my extension code against Python 2.4 and Python 2.3 regularly, because otherwise issues arise where I wouldn't have expected them, like even simple macros like PyDict_CheckExact not being present in older Python versions. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: python + gcov
[EMAIL PROTECTED] wrote: > [...] Do I need to make a static extension of my imported module to profile > it ? I always bit the bullet and finally just did that. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
[ANN] pysqlite 2.3.3 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 pysqlite 2.3.1 released === I'm pleased to announce the availability of pysqlite 2.3.3. This is a bugfix release. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlite? pysqlite is a DB-API 2.0-compliant database interface for SQLite. SQLite is a relational database management system contained in a relatively small C library. It is a public domain project created by D. Richard Hipp. Unlike the usual client-server paradigm, the SQLite engine is not a standalone process with which the program communicates, but is linked in and thus becomes an integral part of the program. The library implements most of SQL-92 standard, including transactions, triggers and most of complex queries. pysqlite makes this powerful embedded SQL engine available to Python programmers. It stays compatible with the Python database API specification 2.0 as much as possible, but also exposes most of SQLite's native API, so that it is for example possible to create user-defined SQL functions and aggregates in Python. If you need a relational database for your applications, or even small tools or helper scripts, pysqlite is often a good fit. It's easy to use, easy to deploy, and does not depend on any other Python libraries or platform libraries, except SQLite. SQLite itself is ported to most platforms you'd ever care about. It's often a good alternative to MySQL, the Microsoft JET engine or the MSDE, without having any of their license and deployment issues. pysqlite can be downloaded from http://pysqlite.org/ - Sources and Windows binaries for Python 2.5, 2.4 and Python 2.3 are available. === CHANGES === - - self->statement was not checked while fetching data, which could lead to crashes if you used the pysqlite API in unusual ways. Closing the cursor and continuing to fetch data was enough. - - Converters are stored in a converters dictionary. The converter name is uppercased first. The old upper-casing algorithm was wrong and was replaced by a simple call to the Python string's upper() method instead. - -Applied patch by Glyph Lefkowitz that fixes the problem with subsequent SQLITE_SCHEMA errors. - - Improvement to the row type: rows can now be iterated over and have a keys() method. This improves compatibility with both tuple and dict a lot. - - A bugfix for the subsecond resolution in timestamps. - - Corrected the way the flags PARSE_DECLTYPES and PARSE_COLNAMES are checked for. Now they work as documented. - - gcc on Linux sucks. It exports all symbols by default in shared libraries, so if symbols are not unique it can lead to problems with symbol lookup. pysqlite used to crash under Apache when mod_cache was enabled because both modules had the symbol cache_init. I fixed this by applying the prefix pysqlite_ almost everywhere. Sigh. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFqYQ5dIO4ozGCH14RAlvkAKCAXPZJSPqX6lZMWvAgZPwbbznEXwCdEvPv d3deYn5TZsQ4xn2VEcw+WBE= =U221 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite user-defined functions & unicode issue
Ben Wolfson wrote: I've got a db some of whose elements have been created automatically from filesystem data (whose encoding is iso-8859-1). If I try to select one of those elements using a standard SQL construct, things work fine: [...] How can I get around this? I really want to be able to search by regexp, and not just the standard SQL %-pattern. Looks like SQLite does not want to pass non-UTF8 strings to functions. The attached script shows that it does work with unicode and buffer (BLOB) parameters, but not with non-UTF8 strings. Text has to be encoded in UTF-8 in SQLite, it's just not enforced usually. Looks like SQLite enforces it here, though. Kind of ... -- Gerhard import sqlite3 as sqlite import re def func(x): if x is not None: return "ok" else: return "input data did not arrive" con = sqlite.connect(":memory:") con.create_function("func", 1, func) raw_latin1 = unicode("\x86", "latin1").encode("utf-8") print raw_latin1 unicode_str = unicode(raw_latin1, "latin1") as_buffer = buffer(raw_latin1) def test(input_data): try: print "-" * 50 print type(input_data) print con.execute("select func(?)", (input_data,)).fetchone()[0] except Exception, e: print "ERROR", e test(raw_latin1) test(unicode_str) test(as_buffer) -- http://mail.python.org/mailman/listinfo/python-list
Next meeting of the Hamburg Python User Group
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, if you happen to be in Hamburg, Germany at November, 14th, and you'd like to meet fellow Pythonistas, you should come to Jarrestraße 46 at DDD design, who are generously hosting us again. We will start at 19:30 and this time we will have a presentation again. It will be about SQLAlchemy and I will do it. Hamburg's Pythonistas can be found online in the Google Group http://groups.google.com/group/hamburg-pythoneers Cheers, Gerhard -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHMPLSdIO4ozGCH14RAnpIAJ9aWSDLKL5RyU1GSZT/KItWEvDr3gCffHYg lF3y9LUmu+FLnCooBX7RrY4= =OSsp -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for a good Python environment
[EMAIL PROTECTED] wrote: > Hey, I'm looking for a good Python environment. That is, at least an > editor and a debugger, and it should run on Windows. Does anyone have > any idea? I like ERIC. You can get it at http://www.die-offenbachs.de/eric/eric4-download.html Or just download and install PyQt4, which includes it: http://www.riverbankcomputing.com/Downloads/PyQt4/GPL/PyQt-Py2.5-gpl-4.3.1-1.exe There's also a list of Python IDEs on the Python wiki: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list