My ESP8266 devices are generating huge amount of logs so after some time LogAnalyzer database had over 5M records.
I've decided to delete old data, but before run purge script I want to backup these records.
The solution was quite simple:
where Syslog is database, and SystemEvents is table.
You can also export to CSV (TSV) format if You prefer:
After this I could delete whole year, instead of using script:
Now I've only about 600k records ;-)
If you want to visualise database structure you can use reverse engineering, i.e. SchemaSpy Graphical Database Schema Metadata Browser or mysqlviz (for MySQL only). SchemaSpy is written in Java and support several types of databases, mysqlviz is in PHP. Both use Graphviz which you have to install separately.
There is a GUI for SchemaSpy - SchemaSpyGUI. To work with MySQL you need MySQL Connector/J - it's a little bit tricky because it's install in x86 patch even if you install 64 bit version of MySQL - at least in MS Windows.
In my case "Patch to DB driver" looks like this:
The output is browsable "web page" about structure of analysed database.
Mysqlviz is simple PHP script - you have to prepare database dump in special format - special means different than generated by MySQL Workbench. You have to omit schema in dump (it is simple option in export options), but you have also check if CONSTRAINT are in single line. Dump generated by Workbench divide it into few lines. So you have to (I did it manually but I would prefer sed/awk) change this:
into (long) single-line entry:
then you can generate DOT file:
and open created in Graphviz.
Szukając narzędzi do projektowania baz w PostgreSQL'u natknąłem się na program do tworzenia aplikacji WaveMaker.
Wygląda przyzwoicie i jest OpenSource. Standardowo działa także z bazą PostgreSQL. Nie mam teraz czasu mu się dokładnie przyjrzeć i potestować, ale może kiedyś się przyda.
Dawno tego nie robiłem, więc już zapomniałem co począć ze świeżo zaistalowanym serwerem PostgreSQL'a. To to pokolei:
inicjuję bazę
podłączam się do bazy
taka konstrukacja to dla tego, że użytkownik root nie ma dostępu do bazy
zakładam użytkowninka
ustawiam mu hasło
zakładam bazę
Zamiast tworzyć użytkowników i bazy z poziomu użytkownika postgres można zmienić w pliku /var/lib/pgsql/data/pg_hba.conf metodę autoryzacji z ident na trust w wierszu
,ale to rozwiązanie nie jest bezpieczne, bo autoryzuje każdego użytkownika podłączającego się lokalnie. Docelowo można zmienić metodę autoryzacji na md5.
Żeby wymusić połączenie po IP a nie po gniazdach (ang. socket) można dodać parametr -h localhost.
Add comment