Skip to content

Commit 851ab97

Browse files
committed
init commit
1 parent d722f0c commit 851ab97

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

inserting-vars-mysql.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import MySQLdb
2+
3+
4+
# replace mysql.server with "localhost" if you are running via your own server!
5+
# server MySQL username MySQL pass Database name.
6+
conn = MySQLdb.connect("mysql.server","beginneraccount","cookies","beginneraccount$tutorial")
7+
8+
c = conn.cursor()
9+
10+
c.execute("SELECT * FROM taula")
11+
12+
rows = c.fetchall()
13+
14+
for eachRow in rows:
15+
print eachRow

mysql-live-db-example.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import MySQLdb
2+
import time
3+
4+
# replace mysql.server with "localhost" if you are running via your own server!
5+
# server MySQL username MySQL pass Database name.
6+
conn = MySQLdb.connect("mysql.server","beginneraccount","cookies","beginneraccount$tutorial")
7+
8+
c = conn.cursor()
9+
10+
username='python'
11+
12+
tweet='man im so cool'
13+
14+
c.execute("INSERT INTO taula (time, username, tweet) VALUES (%s,%s,%s)",
15+
(time.time(), username, tweet))
16+
17+
conn.commit()
18+
19+
c.execute("SELECT * FROM taula")
20+
21+
rows = c.fetchall()
22+
23+
for eachRow in rows:
24+
print eachRow

0 commit comments

Comments
 (0)