Skip to content

Commit 73c0105

Browse files
committed
add
1 parent f5c39c7 commit 73c0105

157 files changed

Lines changed: 9565 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.DS_Store

6 KB
Binary file not shown.

99.PythonStackTutorial/.DS_Store

8 KB
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#__author:jack
2+
#date 2020-03-02 13:55
3+
4+
# pip3 install pymysql
5+
# python3 -m pip install --upgrade pip
6+
import pymysql
7+
# ORM sqlalchemy
8+
def test():
9+
# 创建连接
10+
conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='mysql123', db='home')
11+
# 创建游标
12+
cursor = conn.cursor()
13+
14+
# 执行SQL,并返回收影响行数
15+
effectRow = cursor.execute("update test set txt = '123'")
16+
print(effectRow)
17+
# 执行SQL,并返回受影响行数
18+
#effectRow = cursor.execute("update hosts set host = '1.1.1.2' where nid > %s", (1,))
19+
20+
# 执行SQL,并返回受影响行数
21+
#effectRow = cursor.executemany("insert into hosts(host,color_id)values(%s,%s)", [("1.1.1.11",1),("1.1.1.11",2)])
22+
23+
cursor.execute("select * from test")
24+
row = cursor.fetchone()
25+
print(row)
26+
27+
# 提交,不然无法保存新建或者修改的数据
28+
conn.commit()
29+
30+
# 关闭游标
31+
cursor.close()
32+
# 关闭连接
33+
conn.close()
34+
35+
36+
if __name__ == '__main__':
37+
test()
38+
print("===")
6 KB
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#__author:jack
2+
#date 2020-03-02 13:55
3+
4+
import socket
5+
6+
def main():
7+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
8+
sock.bind(('localhost',8082))
9+
sock.listen(5)
10+
11+
while True:
12+
connection, address = sock.accept()
13+
buf = connection.recv(1024)
14+
print(buf.decode('utf8'))
15+
16+
connection.sendall(bytes("HTTP/1.1 201 OK\r\n\r\n","utf8"))
17+
connection.sendall(bytes("<h1 style='color:black'>Hello,World</h1>","utf8"))
18+
19+
20+
connection.close()
21+
22+
if __name__ == '__main__':
23+
24+
main()
6 KB
Binary file not shown.

99.PythonStackTutorial/09.web/10.user_manager/app01/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class App01Config(AppConfig):
5+
name = 'app01'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.10.2 on 2016-12-02 02:47
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
initial = True
12+
13+
dependencies = [
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='Administrator',
19+
fields=[
20+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('username', models.CharField(max_length=32)),
22+
('password', models.CharField(max_length=32)),
23+
],
24+
),
25+
migrations.CreateModel(
26+
name='Classes',
27+
fields=[
28+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
29+
('caption', models.CharField(max_length=32)),
30+
],
31+
),
32+
migrations.CreateModel(
33+
name='Student',
34+
fields=[
35+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
36+
('name', models.CharField(max_length=32)),
37+
('cls', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app01.Classes')),
38+
],
39+
),
40+
migrations.CreateModel(
41+
name='Teacher',
42+
fields=[
43+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
44+
('name', models.CharField(max_length=32)),
45+
('cls', models.ManyToManyField(to='app01.Classes')),
46+
],
47+
),
48+
]

0 commit comments

Comments
 (0)