Questions
Find answers to frequently asked development questions. For information about Better Stack products, explore our docs.
How can I safely create a nested directory in Python?
The most common way to safely create a nested directory in Python is using the pathlib or os modules. Using pathlib You can create a nested directory in python 3.5 or later using the Path and mkdir...
How Execute a Program or Call a System Command in Python?
In Python, you can execute a system command using the os.system. However, subprocess.run is a much better alternative. The official also documentation recommends subprocess.run over the os.system. ...
How do I merge two dictionaries in a single expression in Python?
To merge two dictionaries in a single expression you can use the dictionary unpacking operator **. This creates a new dictionary and unpacks all key-value pairs into the new dictionary. Let’s look ...
How do I check whether a file exists without exceptions?
There are two ways you can safely check if a file exists at a given path. Using the os.path You can use the exists function from the os.path package to check if a file exists at the given path. fro...
What are metaclasses in Python?
In Python, a metaclass is the class of a class. It defines how a class behaves, including how it is created and how it manages its instances. A metaclass is defined by inheriting from the built-in ...
How to use the ternary conditional operator in Python?
The ternary conditional operator is a shortcut when writing simple conditional statements. If the condition is short and both true and false branches are short too, there is no need to use a multi-...
What Does if name == “main”: Do in Python?
The if __name__ == "main" is a guarding block that is used to contain the code that should only run went the file in which this block is defined is run as a script. What it means is that if you run...
What Does the “yield” Keyword Do in Python?
To better understand what yield does, you need first to understand what generator and iterable are. What is iterable When you use a list or list-like structure, you can read the values from the lis...
Where can I find MySQL logs in phpMyAdmin?
In the older version of the phpMyAdmin control panel, there is Binary log in which all logs are stored. This can be opened by clicking Status → Binary log In newer versions, the Status page looks l...
Where can I find error log files for PHP?
PHP stores error logs in /var/log/apache2 if PHP is an apache2 module. Shared hosts are often storing log files in your root directory /log subdirectory. If you are using cPanel, the master log is ...
Where are PostgreSQL logs stored?
PostgreSQL stores logs in the log files. Depending on your system, you can find the logs at the following locations: Ubuntu On Ubuntu and Ubuntu-like systems, the PostgreSQL log is stored in the /v...
Where are PHP logs stored?
PHP stores error logs in /var/log/apache2 if PHP is an apache2 module. Shared hosts are often storing log files in your root directory /log subdirectory. If you are using cPanel, the master log is ...
Where are MySQL logs stored?
The official distributions for individual UNIX/Linux platforms are typically script-based, with little or no interactive configuration during installation. Some installation packages (including Yum...
MySQL/Writing file error (Errcode 28)
If you have received an MySQL error with the error code and don’t know what the code means, you can use the perror command to display the text explanation of the error code. perror 28 Output: OS er...
Log all queries in MySQL
In MySQL, it is possible to log all queries that were executed. You can view them as a table or file. Output query history into a table To output executed queries into a table, run the following My...
How to show the last queries executed on MySQL?
In MySQL, it is possible to show the last queries that were executed. You can view them as a table or file. Output query history into a table To output executed queries into a table, run the follow...
How to log PostgreSQL queries?
If you would like to log all PostgreSQL queries into a file, you can do that by changing few settings int the configuration file Open the data/postgresql.conf file and change the following settings...
How to Get the Query Executed in Laravel 5
By default, the query log is disabled in Laravel 5: Don’t worry, you can enable the query log by running the following: // enable query log DB::enableQueryLog(); Then you can display the log like t...
How to enable MySQL Query Log?
MySQL query log stores the history of executed queries. This history is stored in a log file. On busy servers, this file ca grow very large. To enable the query log, put the following line into /et...
How to do error logging in CodeIgniter (PHP)
Code igniter has logging capabilities built-in. Make sure you do the following: Make your /application/logs folder writable In /application/config/config.php set the following: $config['log_thresho...
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for usBuild on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github
Thank you to everyone who
Here is to all the fantastic people that are contributing and sharing their amazing projects: Thank you!