Skip to content

Tag: python

How to create a new database using SQLAlchemy?

Using SQLAlchemy, an Engine object is created like this: Accessing engine fails if the database specified in the argument to create_engine (in this case, mydb) does not exist. Is it possible to tell SQLAlchemy to create a new database if the specified database doesn’t exist? Answer On postgres, three da…

How to have Calendar thing in Django date field

I have this Datetime field in Django But I want the Calendar to pop up. In docs, they say to write this Now I have a few problems: Where to declare this class and how to use it I don’t have pretty.css , animation.css , how can get it Do I need to do programming for it?? Answer The files

How to get a list of all the Python standard library modules?

I want something like sys.builtin_module_names except for the standard library. Other things that didn’t work: sys.modules – only shows modules that have already been loaded sys.prefix – a path that would include non-standard library modules and doesn’t seem to work inside a virtualenv…

How to convert an H:MM:SS time string to seconds in Python?

Basically I have the inverse of this problem: Python Time Seconds to h:m:s I have a string in the format H:MM:SS (always 2 digits for minutes and seconds), and I need the integer number of seconds that it represents. How can I do this in python? For example: “1:23:45” would produce an output of 50…

HTTP requests and JSON parsing in Python [duplicate]

This question already has answers here: How can I parse (read) and use JSON? (5 answers) What are the differences between the urllib, urllib2, urllib3 and requests module? (11 answers) Closed last month. I want to dynamically query Google Maps through the Google Directions API. As an example, this request cal…

python win32 COM closing excel workbook

I open several different workbooks (excel xlsx format) in COM, and mess with them. As the program progresses I wish to close one specific workbook but keep the rest open. How do I close ONE workbook? (instead of the entire excel application) Answer The the Workbook COM object has a Close() method. Basically, …