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
7cfb16a4
Commit
7cfb16a4
authored
Nov 21, 2023
by
崔为之
💪🏽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project
parent
ee420830
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
44 deletions
+84
-44
application/extensions/init_sqlalchemy.py
application/extensions/init_sqlalchemy.py
+40
-40
application/script/cmdline.py
application/script/cmdline.py
+44
-4
No files found.
application/extensions/init_sqlalchemy.py
View file @
7cfb16a4
...
...
@@ -39,43 +39,43 @@ def init_database(app: Flask) -> None:
app
.
config
.
setdefault
(
'SQLALCHEMY_DATABASE_URI'
,
uri
.
create
())
db
.
app
=
app
db
.
init_app
(
app
)
with
app
.
app_context
():
db
.
session
.
execute
(
text
(
f
"""
CREATE TABLE IF NOT EXISTS
{
cfg
.
TableName
}
(
id SERIAL NOT NULL,
date_time TIMESTAMP WITH TIME ZONE NOT NULL,
uuid varchar(100) DEFAULT NULL,
mid varchar(50) DEFAULT NULL,
mid_type varchar(50) DEFAULT NULL,
mac_wifi varchar(50) DEFAULT NULL,
mac_voice varchar(50) DEFAULT NULL,
code smallint DEFAULT NULL,
query varchar(255) DEFAULT NULL,
terminal_domain varchar(50) DEFAULT NULL,
terminal_intent varchar(50) DEFAULT NULL,
distribution_gree_domain varchar(50) DEFAULT NULL,
distribution_gree_intent varchar(50) DEFAULT NULL,
response_text text,
emotion_class varchar(50) DEFAULT NULL,
skill_id varchar(100) DEFAULT NULL,
voice_portal smallint NOT NULL,
service_nlu varchar(50) DEFAULT NULL,
service_type smallint NOT NULL,
slots text,
yzs_request_id varchar(50) DEFAULT NULL,
yzs_remote_ip varchar(15) DEFAULT NULL,
yzs_app_key varchar(50) DEFAULT NULL,
yzs_ud_id varchar(50) DEFAULT NULL,
yzs_user_id varchar(50) DEFAULT NULL,
yzs_intent text,
yzs_general text,
yzs_nlu_time varchar(20) DEFAULT NULL,
get_body_time varchar(20) DEFAULT NULL,
gree_nlu_time varchar(20) DEFAULT NULL,
get_homeid_time varchar(20) DEFAULT NULL,
tencent_nlu_time varchar(20) DEFAULT NULL,
cost_time varchar(20) DEFAULT NULL,
PRIMARY KEY (id, date_time)
) PARTITION BY RANGE (date_time);
"""
))
db
.
session
.
commit
()
#
with app.app_context():
#
db.session.execute(text(f"""
#
CREATE TABLE IF NOT EXISTS {cfg.TableName} (
#
id SERIAL NOT NULL,
#
date_time TIMESTAMP WITH TIME ZONE NOT NULL,
#
uuid varchar(100) DEFAULT NULL,
#
mid varchar(50) DEFAULT NULL,
#
mid_type varchar(50) DEFAULT NULL,
#
mac_wifi varchar(50) DEFAULT NULL,
#
mac_voice varchar(50) DEFAULT NULL,
#
code smallint DEFAULT NULL,
#
query varchar(255) DEFAULT NULL,
#
terminal_domain varchar(50) DEFAULT NULL,
#
terminal_intent varchar(50) DEFAULT NULL,
#
distribution_gree_domain varchar(50) DEFAULT NULL,
#
distribution_gree_intent varchar(50) DEFAULT NULL,
#
response_text text,
#
emotion_class varchar(50) DEFAULT NULL,
#
skill_id varchar(100) DEFAULT NULL,
#
voice_portal smallint NOT NULL,
#
service_nlu varchar(50) DEFAULT NULL,
#
service_type smallint NOT NULL,
#
slots text,
#
yzs_request_id varchar(50) DEFAULT NULL,
#
yzs_remote_ip varchar(15) DEFAULT NULL,
#
yzs_app_key varchar(50) DEFAULT NULL,
#
yzs_ud_id varchar(50) DEFAULT NULL,
#
yzs_user_id varchar(50) DEFAULT NULL,
#
yzs_intent text,
#
yzs_general text,
#
yzs_nlu_time varchar(20) DEFAULT NULL,
#
get_body_time varchar(20) DEFAULT NULL,
#
gree_nlu_time varchar(20) DEFAULT NULL,
#
get_homeid_time varchar(20) DEFAULT NULL,
#
tencent_nlu_time varchar(20) DEFAULT NULL,
#
cost_time varchar(20) DEFAULT NULL,
#
PRIMARY KEY (id, date_time)
#
) PARTITION BY RANGE (date_time);
#
"""))
#
db.session.commit()
application/script/cmdline.py
View file @
7cfb16a4
...
...
@@ -13,6 +13,7 @@
# Import third-party modules
import
click
from
flask.cli
import
with_appcontext
from
sqlalchemy
import
text
@
click
.
command
(
"init"
)
...
...
@@ -26,7 +27,46 @@ def init():
from
application.extensions.init_sqlalchemy
import
db
# Uncomment below lines to create a new log entry.
# click.echo("create log")
# db.session.add(user)
# db.session.commit()
# click.echo("created log")
click
.
echo
(
'create tables'
)
with
db
.
app
.
app_context
():
cfg
=
db
.
app
.
config
.
Database
db
.
session
.
execute
(
text
(
f
"""
CREATE TABLE IF NOT EXISTS
{
cfg
.
TableName
}
(
id SERIAL NOT NULL,
date_time TIMESTAMP WITH TIME ZONE NOT NULL,
uuid varchar(100) DEFAULT NULL,
mid varchar(50) DEFAULT NULL,
mid_type varchar(50) DEFAULT NULL,
mac_wifi varchar(50) DEFAULT NULL,
mac_voice varchar(50) DEFAULT NULL,
code smallint DEFAULT NULL,
query varchar(255) DEFAULT NULL,
terminal_domain varchar(50) DEFAULT NULL,
terminal_intent varchar(50) DEFAULT NULL,
distribution_gree_domain varchar(50) DEFAULT NULL,
distribution_gree_intent varchar(50) DEFAULT NULL,
response_text text,
emotion_class varchar(50) DEFAULT NULL,
skill_id varchar(100) DEFAULT NULL,
voice_portal smallint NOT NULL,
service_nlu varchar(50) DEFAULT NULL,
service_type smallint NOT NULL,
slots text,
yzs_request_id varchar(50) DEFAULT NULL,
yzs_remote_ip varchar(15) DEFAULT NULL,
yzs_app_key varchar(50) DEFAULT NULL,
yzs_ud_id varchar(50) DEFAULT NULL,
yzs_user_id varchar(50) DEFAULT NULL,
yzs_intent text,
yzs_general text,
yzs_nlu_time varchar(20) DEFAULT NULL,
get_body_time varchar(20) DEFAULT NULL,
gree_nlu_time varchar(20) DEFAULT NULL,
get_homeid_time varchar(20) DEFAULT NULL,
tencent_nlu_time varchar(20) DEFAULT NULL,
cost_time varchar(20) DEFAULT NULL,
PRIMARY KEY (id, date_time)
) PARTITION BY RANGE (date_time);
"""
))
db
.
session
.
commit
()
click
.
echo
(
'created tables'
)
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