flet publish main.py or flet build web --project main -v (2003, "Can't connect to MySQL server on 's16.link-host.net' (timed out)")
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 17k
- Forks
- 694
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 33
Description
If I run flet run '.\main.py' then everything works fine.
but if I do 'flet publish main.py' and 'run python -m http.server --directory .\dist'
I follow the link 'http://localhost:8000/'
the program starts but I get an error from the console browser
(2003, "Can't connect to MySQL server on 's16.link-host.net' (timed out)")
import flet as ft
import peewee as pe
name_db = 'siroz436_test'
host_db = 's16.link-host.net'
port_db = 3306
user_db = 'siroz436_sirozza'
password_db = '7iFlGmh2Ze'
db = pe.MySQLDatabase(name_db, host=host_db, port=port_db, user=user_db,
password=password_db, connect_timeout=100)
class BaseModel(pe.Model):
class Meta:
database = db
class Prices(BaseModel):
id = pe.AutoField(),
price_prices = pe.DecimalField()
active_prices = pe.BooleanField()
class Meta:
table_name = 'prices'
def get_price_db():
try:
with db.atomic():
data_prices = Prices.select().order_by(Prices.id)
print(data_prices)
return data_prices
except Exception as e:
print(e)
return False
class GeneralTable(ft.DataTable):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.column_spacing = 50
self.sort_column_index = 0
self.sort_ascending = True
self.show_checkbox_column = True
self. adaptive = True
price_table = GeneralTable(
columns=[
ft.DataColumn(ft.Text('#')),
ft.DataColumn(ft.Text('price')),
ft.DataColumn(ft.Text('active')),
ft.DataColumn(ft.Text('action')),
],)
snack_bar_error = ft.SnackBar(ft.Text(f'Error'),bgcolor=ft.colors.RED_ACCENT)
snack_bar_ok = ft.SnackBar(ft.Text(f'OK'),bgcolor=ft.colors.GREEN_ACCENT)
async def get_prices():
get_all = get_price_db()
price_table.rows.clear()
if get_all == True:
for price in get_all:
price_table.rows.append(
ft.DataRow(
cells=[
ft.DataCell(ft.Text(price.id)),
ft.DataCell(ft.Text(price.price_prices)),
ft.DataCell(ft.Text(price.active_prices)),
ft.DataCell(ft.Row([
ft.IconButton(icon=ft.icons.EDIT,
icon_color='red',
data=price,
tooltip='edit',
on_click=None),
],)),]))
snack_bar_ok.open = True
else:
snack_bar_error.open = True
data_price_table = ft.Row([price_table, snack_bar_error, snack_bar_ok], alignment=ft.MainAxisAlignment.CENTER)
async def main(page: ft.Page):
page.vertical_alignment = ft.MainAxisAlignment.START
page.title = 'Test'
await get_prices()
page.add(data_price_table)
page.update()
ft.app(main, assets_dir='assets')
getting data from database
Flet version (pip show flet):
Name: flet
Version: 0.21.2
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: C:\GitHub\www\.venv\Lib\site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog
Required-by:
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:15:12) [MSC v.1937 32 bit (Intel)] on win32
Give your requirements.txt file (don't pip freeze, instead give direct packages):
flet
micropip
websockets
wsproto
peewee
pymysql
(The database is working and can be connected and tested.)
Operating system:
Windows 11,
on the server side where the database is installed
Apache | 2.4.37-62.module_el8.9.0+3646+acd210d0,
MySQL | 8.0.32-1.module_el8.8.0+3567+56a616e4,
PHP | 7.2.24-1.module_el8.3.0+2010+7c76a223,
Perl | 5.26.3-422.el8.0.1,
Kernel | 4.18.0-513.9.1.el8_9.x86_64
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied main.py with flet publish main.py and flet build web, comparing it with the working flet run command. Inspect the published web runtime and the listed peewee, pymysql, and micropip dependencies to determine where the MySQL connection fails. Done requires a confirmed cause and an agreed fix or documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python
- Domain
- database, web-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 18/100