Python MySql
Simple use of MySql Python
2:
mysql> CREATE TABLE pc_data (
-> pc_id INT NOT NULL AUTO_INCREMENT,
-> pc_title VARCHAR(100) NOT NULL,
-> pc_command VARCHAR(100) NOT NULL,
-> pc_ip VARCHAR(100) NOT NULL,
-> pc_result VARCHAR(200) NOT NULL,
-> PRIMARY KEY ( pc_id )
-> );
cursor.execute("INSERT INTO pc_data ( pc_title, pc_command, pc_ip, pc_result)1:
VALUES ( "PC", "ipconfig", ipaddress, useragent );")
>>import _mysql
>>db=_mysql.connect()
>>db=_mysql.connect(host="localhost",user="joebob",passwd="moonpie",db="thangs")
>>db.query("select * from comPc where com_id = 1")
>>r = db.use_result()
>>r.fetch_row()
(('3','2','0'),)
>>r.fetch_row()
()
2:
>>import MySQLdb
>>db=MySQLdb.connect(passwd="moonpie",db="thangs")
>>c=db.cursor()
>>c.execute("select * from comPc")
>>c.fetchone()
(3L, 2L, 0L)
Comments
Post a Comment