
python comic
This blog is not a political blog, the rest of content is about Python Programming.It is also NOT for Python the Snake
189MB | iso | ![]() | v 6.0.7 | [ md5 ] | |
189MB | tar | ![]() | v 6.0.7 | [ md5 |
This step-by-step howto shows a basic setup for Apache 2 web server. Apache is installed on Ubuntu 6.06 LTS Dapper, but instructions will probably work on any Ubuntu. This document is a work in progress, initially only required commands are listed without troughout explanations.
© 2006 Tero Karvinen. GNU General Public License, version 2.
$ sudo apt-get install apache2
Surf to your own server on your own local computer:
$ firefox "http://localhost"
Find out how your server is found on the net. Anyone can use your IP address or DNS name to connect to your server:
$ ip addr
Use your own IP address (eth0, first IP number, does not end .255)
$ firefox "http://1.2.3.4"
If DNS is working on your network, you can see your fully qualified domain name with:
$ host 1.2.3.4
With user homepages, anything you put in public_html in your home directory is published on the web.
For newer Ubuntu such as 8.04 Hardy, you have to explicitly enable userdir module. On older ones such as 6.06 LTS Dapper, userdir is enabled by default.
$ sudo a2enmod userdir
$ sudo /etc/init.d/apache2 restart
Go to your home directory
$ cd
Create a folder for public html files, note the underscore ‘_’
$ mkdir public_html
Check your name
$ whoami
Surf to ~yourname:
$ firefox "http://localhost/~tkarvine/"
You should see a directory listing of an empty directory. You can also try it using your IP address and a different machine.
If you see your homepage, well done. You have successfully installed a server with user homepages. You can create some web pages with OpenOffice and save them to your public_html directory.Return a result record of the query
For example:for row in cur.fetchall( ):
- fetchall( ) - return all as a tuple
print "name",row[0], "address",row[1]
2. fetchone( ) - return first row
for row in cur.fetchone( ):
print "............................
3. fetchmany( size) - return row according to size
for row in cur.fetchmany(200)
print "%s | %s |%s" %row
name_last age
------------------------------------------------------------------------------
Putin 51
Lebed 53
Zhirinovsky 57
Yeltsin 72
import sys
# input a original file
inp = open("december.txt","r")
#write to a new file
outp = open("newDecember.txt","w")
#declare global
lines = inp.readlines()
for line in lines:
#find the string
if(line.find("asfgsfhhshas")!=-1):
## print line
#write to a new file
sys.stdout.write(line)
outp.write(line)
inp = open("december.txt","r")
badf = open("badDecember.txt","w")
goodf = open("goodDecember.txt",'w')
lines = inp.readlines()
for line in lines:
if line.find("asfgsfhhshas") != -1:
sys.stdout.write(line)
badf.write(line)
else:
goodf.write(line)
badf.close()
goodf.close()
inp.close()
Database is a structured collection of data that is stored in a computer. A computer program, that manages and queries a database is calles a Database Management System (DBMS). Some thirty years ago, DBMS were available only in the research laboratories of giant companies like IBM. Later on, they began to spread. But they were very expensive. These days, we can found DBMS everywhere. On the web, on our personal computers, in various mobile devices or portables. We can have many different databeses for little or no money that would cost thousands of dollars in the past. We live in interesting times.
There are various database models. The most significant database model is the relational database model (RDBMS). The data is divided into tables. Among these tables we define relations. We all have heard about various database management systems. There are several well known commercial DBMS as well as open source ones.
Commercial RDBMS
| Opensource RDBMS
|
Starting from Python 2.5.x series, an SQLite library is included in the python language. SQLite is a small embeddable library. This means that programmers can integrate the libraty inside their applications. No server is needed to work with SQLite. Therefore SQLite is also called a zero-configuration SQL database engine.
SQLite has the following features.
SQLite supports these data types:
Before we start working with SQLite, we define some important terms. A database query is a search for information from a database. A query is written in SQL language. Structured Query Language (SQL) is a computer language used to create, retrieve, update and delete data from the database. It was developed by the IBM corporation. SQL language has three subsets.
filename means you must replace the text filename with the name of the file including extension that you are using.
C:\Python23 is an example; replace C:\Python23 with the actual drive letter and directory where your Python is installed.
If standard Python file extensions like .py are associated with Python (the default for a standard Windows installation) then you can simply double-click a Python source file in Windows Explorer to run the script. There are 2 problems with this method:
raw_input("Press ENTER to continue...")
Using Command Prompt
The windows command prompt can be accessed via START/RUN/CMD
The phrase "Enter the command ..." means type the command at the prompt and press the Enter key.
C:\Python25 is an example; replace C:\Python25 with the actual drive letter and directory where your Python is installed.