-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.py
More file actions
40 lines (32 loc) · 869 Bytes
/
temp.py
File metadata and controls
40 lines (32 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
#!/usr/bin/python
import mysql
import random
# Open database connection
db = mysql.connect("localhost","root","r34lw4r3","infradb")
# prepare a cursor object using cursor() method
cursor = db.cursor()
# Prepare SQL query to INSERT a record into the database.
sql = "SELECT * FROM utenti"
try:
# Execute the SQL command
cursor.execute(sql)
# Fetch all the rows in a list of lists.
results = cursor.fetchall()
for row in results:
id = row[0]
nome = row[1]
cognome = row[2]
ip = row[3]
ip_vpn = row[4]
# Now print fetched result
print "id=%s,nome=%s,cognome=%s,ip=%s,ip_vpn=%s" % \
(id, nome, cognome, sex, income )
except:
print "Errore: Impossibile trovare i dati richiesti"
# disconnect from server
db.close()