Im looking to use a document database such as MongoDB but looking through the documents I cant find much on queries that involve date functions. For example lets say that I'm asking one of the following questions of the DB:
"Tell me all the people who bought a product on tuesday"
"Get me all sales and group by month"
They are random ...
I tried a couple of approaches, I am really only concerned with performance, not correctness. I noticed that the regex based implementation is about 3-4x slower than the one that uses type coercion. Is there another, more efficient way of doing this?
def IsNumber(x):
try:
_ = float(x)
except ValueError:
return Fa...
Within a python script, I want to issue a command. In perl, I could define a command, save it as a variable (here, $cmd) then type system($cmd) and then the command is executed.
How can i do that in python?
...
This view is running fine on plain pyton/Django/mysql on Windows
I'm porting this to run over jython/Django/mysql and it gives error -
Exception received is : error setting index [10] [SQLCode: 0]
Parameter index out of range (10 > number of parameters, which is 0). [SQLCode: 0],
[SQLState: S1009]
The Query is -
cursor.execute(...
I'm trying to use GeoModel python module to quickly access geospatial data for my Google App Engine app.
I just have a few general questions for issues I'm running into.
There's two main methods, proximity_fetch and bounding_box_fetch, that you can use to return queries. They actually return a result set, not a filtered query, which mea...
edit: im asking if global variables are safe in a single-threaded web framework like tornado
im using the mongoengine orm, which gets a database connection from a global variable:
_get_db() # gets the db connection
im also using tornado, a single-threaded python web framework. in one particular view, i need to grab a database conne...
hi all, I'm currently getting the warning:
/var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
from sets import ImmutableSet
everytime I run a python script that uses mysqldb. I'd rather not mess with their lib if possible. I'm on Ubuntu server. Anyone know an easy way to fix t...
I am looking for a Python library for writing Jabber/XMPP clients using the Twisted framework.
...
Hey all!
I am using graphviz's dot to generate some svg graphs for a web application. I call dot using Popen:
p = subprocess.Popen(u'/usr/bin/dot -Kfdp -Tsvg', shell=True,\
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
str = u'long-unicode-string-i-want-to-convert'
(stdout,stderr) = p.communicate(str)
What happends is...
I'm using Google AppEngine and the deferred library, with the Mapper class, as described here (with some improvements as in here). In some iterations of the mapper I get the following error:
CancelledError: The API call datastore_v3.Put() was explicitly cancelled.
The Mapper usually runs fine, I used to have a higher batch size, so th...
Is there any way to achieve the same functionality in Python, i.e., launching a script from a browser and automatically updating it from a central server location?
...
I have a list of (label, count) tuples like this:
[('grape', 100), ('grape', 3), ('apple', 15), ('apple', 10), ('apple', 4), ('banana', 3)]
From that I want to sum all values with the same label (same labels always adjacent) and return a list in the same label order:
[('grape', 103), ('apple', 29), ('banana', 3)]
I know I could sol...
I'm writing a simple site spider and I've decided to take this opportunity to learn something new in concurrent programming in Python. Instead of using threads and a queue, I decided to try something else, but I don't know what would suit me.
I have heard about Stackless, Celery, Twisted, Tornado, and other things. I don't want to have ...
How can you check the contents of a file with python, and then copy a file from the same folder and move it to a new location?
I have Python 3.1 but i can just as easily port to 2.6
thank you!
...
I'm currently indexing my music collection with python. Ideally I'd like my output file to be formatted as;
"Artist;
Album;
Tracks - length - bitrate - md5
Artist2;
Album2;
Tracks - length - bitrate - md5"
But I can't seem to work out how to achieve this. Any suggestions?
...
Let's say I have 3 django apps, app Country, app Social and app Financial.
Country is a 'master navigation' app. It lists all the countries in a 'index' view and shows details for each country on its 'details' view.
Each country's details include their Social details (from the social app) and their Financial details (from the financia...
I am new to Ruby. I'm looking to import functions from a module that contains a tool I want to continue using separately. In Python I would simply do this:
def a():
...
def b():
...
if __name__ == '__main__':
a()
b()
This allows me to run the program or import it as a module to use a() and/or b() separately. What's ...
I am running MySQL 5.1 on my windows vista installation. The table in question uses MyISAM, has about 10 million rows. It is used to store text messages posted by users on a website.
I am trying to run the following query on it,
query = "select id, text from messages order by id limit %d offset %d" %(limit, offset)
where limit is se...
I'm trying to find all strings of the format {{rdex|001|001|Bulbasaur|2|Grass|Poison}} in a large text file, and then extract the substrings corresponding to the first 001 and to Bulbasaur, perhaps as a tuple.
I'm assuming regex with capturing groups can be used for both; could anybody tell me the appropriate regex to use in Python 3.1 ...
Sorry. I am not trying to start any flame. My scripting experience is from Perl, and I am pretty new in Python.
I just want to check whether I can have the same degree of flexibility as in Python.
In Python :
page = form.getvalue("page")
str = 'This is string : ' + str(int(page) + 1)
In Perl :
$str = 'This is string : ' . ($page + ...