Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
崔为之
elp
Commits
1c14fa79
Commit
1c14fa79
authored
Nov 12, 2023
by
崔为之
💪🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project
parent
48201a87
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
application/config/config.yaml
application/config/config.yaml
+1
-1
application/libs/helper/__init__.py
application/libs/helper/__init__.py
+1
-0
application/libs/tasks/task.py
application/libs/tasks/task.py
+18
-6
No files found.
application/config/config.yaml
View file @
1c14fa79
...
...
@@ -33,7 +33,7 @@ Logger:
Retention
:
Scheduler
:
Start
:
2023-11-12 1
0:04
:00
Start
:
2023-11-12 1
2:08
:00
End
:
2099-11-11 16:00:00
Timezone
:
Asia/Shanghai
...
...
application/libs/helper/__init__.py
View file @
1c14fa79
...
...
@@ -13,3 +13,4 @@
from
.config
import
ConfigHelper
from
.env
import
EnvVarHelper
from
.file
import
FileHelper
from
.mysql
import
MySQLHelper
application/libs/tasks/task.py
View file @
1c14fa79
...
...
@@ -14,6 +14,7 @@ import datetime
from
application.extensions.init_sqlalchemy
import
db
from
application.models
import
User
from
application.common
import
global_config
from
application.libs.helper
import
MySQLHelper
def
task
():
...
...
@@ -23,9 +24,20 @@ def task():
:return: None
"""
with
db
.
app
.
app_context
():
cfg
=
db
.
app
.
config
.
ExtraDB
options
=
{
"host"
:
cfg
.
Host
,
"user"
:
cfg
.
User
,
"password"
:
cfg
.
Password
,
"database"
:
cfg
.
DB
,
"port"
:
cfg
.
Port
,
}
with
MySQLHelper
(
**
options
)
as
helper
:
print
(
helper
.
execute
(
cfg
.
Sql
))
print
(
"create user"
)
user
=
User
(
username
=
"CWzz"
,
email
=
"Stuu@outlook.com"
,
password
=
"qwe!2345"
,
active
=
True
,
created_at
=
datetime
.
datetime
.
utcnow
())
user
.
save
()
#
user = User(username="CWzz", email="Stuu@outlook.com", password="qwe!2345", active=True,
#
created_at=datetime.datetime.utcnow())
#
user.save()
print
(
db
.
app
.
config
)
print
(
"created user admin"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment