Nội dung buổi Tutorial ngày hôm nay
Buổi hôm nay mình có cover các nội dung như sau:
import json
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.request import SharePointRequest
request = SharePointRequest(site_url).with_credentials(UserCredential("{username}", "{password}"))
response = request.execute_request("web")
json = json.loads(response.content)
web_title = json['d']['Title']
print("Web title: {0}".format(web_title))
Rồi từ json data, tạo dataframe như bình thường: df = pd.DataFrame([json])
import pyocdb
# Connect to the database
connection = pyodbc.connect("Driver={Driver_Name};"
"Server=server_name;"
"Database=database_name;"
"UID=user_id;"
"PWD=password;")
# Create a cursor object
cursor = connection.cursor()
# Execute a query
cursor.execute("SQL QUERY")
# Fetch results
rows = cursor.fetchall()
# Process results
for row in rows:
print(row) --------> Từ each row tạo dataframe như bình thường
# Close the connection
connection.close()
Cách clean hơn là dùng SQLAlchemy dành cho các bạn muốn nâng cao. Nhưng phải hiểu về class: SQLAlchemy: https://docs.sqlalchemy.org/en/20/orm/quickstart.html
import requests
response = requests.get("https://api.thecatapi.com/")
pd.DataFrame([response.text]) ----> Chuyển thành dataframe rồi làm thao tác như bình thường. Nếu data update liên tục thì có thể schedule Python script
****Mình sẽ nói kĩ hơn về DB và API ở bài số 9 nha.
  • How to secure our streamlit application (force users to login before accessing to the app)? In every company, users' rights are stored in Mircrosoft's Active Directory (simply speaking, it's something like "phuong@mycompany.com - access to unicorns app"). You can link this authorization to your streamlit app. Check out how to set it up here: https://docs.streamlit.io/develop/api-reference/user/st.login. Phần này khá advance nên mình không có đánh vào trọng tâm khi dạy, nhưng chị An có hỏi mình có thể làm được không vì chị ấy muốn recommend solution này cho công ty của chị.
  • Commit code vào git: Bấm Source Control -> Điền tên message -> Bấm commit (như hình) -> Bấm dấu '...' -> Pull, Push -> Push. Làm xong thì code của các bạn sẽ đc update lên trên trang git
  • Upload app lên streamlit community: Các bạn bấm vào link này https://share.streamlit.io và sign in vào GitHub của các bạn. Sau đó bấm Create App -> Deploy Public App From GIthub -> điền thông tin về app của các bạn (như trong hình) -> Deploy. Deploy xong các bạn nhớ quay lại project của các bạn trong Github -> Setting (như hình) -> Scroll tới cuối trang rồi bấm change visibility to Private nha. Như vậy thì khi các bạn chia sẻ streamlit link, code của các bạn sẽ được bảo mật, tránh việc bị đạo code nhen.
  • Mình cũng có thông báo phát động cuộc thi giữa các học viên để các bạn có động lực làm bài, chi tiết mình sẽ post ở một post riêng nha :)
Merci các bạn
0
0 comments
Anne Marie Phuong Bouvard
3
Nội dung buổi Tutorial ngày hôm nay
powered by
Practical Python for Career Up
skool.com/practical-python-for-career-up-1037
Our Data Community is a welcoming space for learners and enthusiasts of all levels to come together, share knowledge, and grow their coding skills.
Build your own community
Bring people together around your passion and get paid.
Powered by