Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bitcoin Telegram Bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s2191814
Bitcoin Telegram Bot
Merge requests
!2
Couldn't fetch the linked file.
Draft: initial user flow for creating a wallet
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Draft: initial user flow for creating a wallet
2-implement_all_user_flows
into
main
Overview
0
Commits
15
Pipelines
0
Changes
2
Merged
Janssen, D.D. (Dylan, Student M-CS)
requested to merge
2-implement_all_user_flows
into
main
2 years ago
Overview
0
Commits
15
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Viewing commit
2d42c121
Prev
Next
Show latest version
2 files
+
69
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
2d42c121
Add peewee ORM
· 2d42c121
s2191814
authored
2 years ago
database.py
0 → 100644
+
67
−
0
Options
from
peewee
import
MySQLDatabase
,
Model
,
CharField
,
BlobField
,
AutoField
from
peewee
import
IntegerField
,
ForeignKeyField
,
DoubleField
import
os
db
=
MySQLDatabase
(
None
)
def
connect
(
create_tables
=
False
)
->
None
:
"""
Initializes the database session and connects to the database
:param create_tables: Creates database tables [default: False]
"""
user
=
os
.
getenv
(
"
DB_USER
"
)
pw
=
os
.
getenv
(
"
DB_PASSWORD
"
)
host
=
os
.
getenv
(
"
DB_HOST
"
)
port
=
os
.
getenv
(
"
DB_PORT
"
)
name
=
os
.
getenv
(
"
DB_DATABASE
"
)
db
.
init
(
name
,
host
=
host
,
port
=
int
(
port
),
user
=
user
,
password
=
pw
)
db
.
connect
()
if
create_tables
:
db
.
create_tables
([
State
,
User
,
Wallet
,
WalletRequest
,
UserWallet
,
PendingTX
])
class
BaseModel
(
Model
):
id
=
AutoField
()
class
Meta
:
database
=
db
class
State
(
BaseModel
):
message
=
CharField
()
menu
=
CharField
()
prev_state
=
IntegerField
()
class
User
(
BaseModel
):
telegram_id
=
IntegerField
()
state_id
=
ForeignKeyField
(
State
)
nickname
=
CharField
()
variables
=
CharField
()
class
Wallet
(
BaseModel
):
max_co_signers
=
IntegerField
()
min_co_signers
=
IntegerField
()
initiator_user_id
=
ForeignKeyField
(
User
,
backref
=
'
users
'
)
name
=
CharField
()
class
WalletRequest
(
BaseModel
):
token
=
CharField
()
wallet_id
=
ForeignKeyField
(
User
,
backref
=
'
walletrequests
'
)
class
UserWallet
(
BaseModel
):
user_id
=
ForeignKeyField
(
User
,
backref
=
'
wallets
'
)
wallet_id
=
ForeignKeyField
(
Wallet
,
backref
=
'
wallets
'
)
class
PendingTX
(
BaseModel
):
from_wallet_id
=
ForeignKeyField
(
Wallet
,
backref
=
'
pendingtx
'
)
to_address
=
CharField
()
amount
=
DoubleField
()
fee_sat_per_byte
=
IntegerField
()
status
=
IntegerField
()
sign_count
=
IntegerField
()
raw_data
=
BlobField
()
txid
=
BlobField
()
Loading