marneu / wireguarddb Goto Github PK
View Code? Open in Web Editor NEWAn AddOn storing wireguard configuration
License: GNU General Public License v3.0
An AddOn storing wireguard configuration
License: GNU General Public License v3.0
Again its me :)
try to connect on Mysql DB
next code:
from wireguard_db.models import DBConfig, DBConnect, WGData, WGRelation
setup = DBConfig().read(config_adapter='mysql')
db_mysql = DBConnect(setup).get()
and my output next:
_> root@node1:/project/wg/wireguardDB# python3 crdb.py
Traceback (most recent call last):
File "crdb.py", line 4, in
db_mysql = DBConnect(setup).get()
File "/project/wg/wireguardDB/wireguard_db/models/database.py", line 33, in init
self.set(setup)
File "/project/wg/wireguardDB/wireguard_db/models/database.py", line 81, in set
self.check()
File "/project/wg/wireguardDB/wireguard_db/models/database.py", line 124, in check
dbtable.create_table(safe=True)
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 6717, in create_table
and cls.table_exists():
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 6707, in table_exists
return cls._schema.database.table_exists(M.table.name, M.schema)
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3326, in table_exists
return table_name in self.get_tables(schema=schema)
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 4042, in get_tables
return [table for table, in self.execute_sql(query, ('VIEW',))]
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3158, in execute_sql
cursor = self.cursor(commit)
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3142, in cursor
self.connect()
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 3096, in connect
self._state.set_connection(self._connect())
File "/usr/local/lib/python3.8/dist-packages/peewee.py", line 4013, in _connect
conn = mysql.connect(db=self.database, **self.connect_params)
File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 353, in init
self.connect()
File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 633, in connect
self._request_authentication()
File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 869, in _request_authentication
authresp = _auth.scramble_caching_sha2(self.password, self.salt)
File "/usr/local/lib/python3.8/dist-packages/pymysql/_auth.py", line 198, in scramble_caching_sha2
p1 = hashlib.sha256(password).digest()
TypeError: object supporting the buffer API required
_
i think my problem in this(i.e. i have DB but show tables; Empty)
File "/project/wg/wireguardDB/wireguard_db/models/database.py", line 33, in init
self.set(setup)
def __init__(self, setup: tuple = None):
"""
Initialize a database connector on given setup
:param config: dict: Optional, the setup from DBConfig.get(), can be setup later
ivar _adapter: str: adapter name
ivar _database: obj: peewee.DatabaseProxy
ivar _connected: bool: connected state of db
"""
self._adapter = None
self._database = None
self._connected = False
if setup:
# full init if setup is given
**self.set(setup)**
FYI little problem YAML file generate with error username instead wguser wgdb
Hello Marcus
I did steps:
python3 -m pip install cython
python3 -m pip install PyMySQL
python3 -m pip install peewee
and create db.py file with your code:
and coy code from this
from wireguard_db.models.config import DBConfig
# now enshure you can write and read the config.yaml
# it will create a /etc/wireguard/wireguard.yaml file
if DBConfig().write():
setup = DBConfig().read()
setup
# you should see a tuple containing the default setup for a sqlite3 connector
exit()
when I run the script I see next
Traceback (most recent call last):
File "db.py", line 1, in
from wireguard_db.models.config import DBConfig
ModuleNotFoundError: No module named 'wireguard_db'
i'll try install module from pip but this failed. also i cand fount setup.py in your repo
pip python -m pip install wireguard_db
ERROR: Could not find a version that satisfies the requirement wireguard_db (from versions: none)
ERROR: No matching distribution found for wireguard_db
could you help me install your module. I want to create DB (25k clients) and use module wireguard. https://github.com/fictivekin/wireguard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.