PostgreSQL
Collection of code recieps to allow you to perform operations on PostgreSQL database. You can acomplish most common database usecases using our recipes, or write your own SQL query get fine tuned results.
Define a new PostgreSQL connection in Python
Define new PostgreSQL database connection and store credentials in .env file. To dofine a new connection provide your: - database name - username - password - host adress - port
Connect to PostgreSQL database in Python
Open new Postgresql database connection, credentials are automatically loaded from .env file. To edit the credentials add them in define new connection recipe.
Show tables from PostgreSQL database
Did you forget table name? Are you using this database for the first time? Maybe some one messed up the schema and now you need to fix it. Check table names on your connection.
Show columns from table in PostgreSQL
Check out columns sand their data types in specified table. Hidden under advanced options is database schema selector, allowing easier querying in large databases.
Create new table using python and PostgreSQL
To create new table give it a name and all its columns, provide data type for every column, and you're done!
Drop table using Python and PostgreSQL
Dropping a table means deleting it for good. Before doing so you might want to back up the table. You can learn about it in this notebook.
Backup table using python
Backing up a table might be useful when you are performing destructive operations. First you can test your changes on a backup and later apply them to the original table.
Update column in table using Python
This recipe lets you to perform simple update operations. If you wish to have finer control consider writing custom SQL queries in raw query recipe.
Select every column from table using python
Selecting every row and column from a table is the simplest way to check table contents. This recipe is best used for those type of scenarios.
Insert row into a table using Python
This notebook will show you how to insert rows into table. Remember that when row is inserted and you want to remove it, you need to do it manually.
Run raw SQL query in python
This recipe unlock full power of SQL, right here you can flex all your muscles and break your caps lock key.
Raw SQL query straight to pandas dataframe
When you want to use combined full powers of SQL and MLJAR studio you land here. A recipe to automatically convert your database data into pandas dataframe object, ready for further analysis.
From database to chart plotting
Using mljar studio's recipes suit you can fetch your data from database, convert it into python object, and plot charts from that data. All without leaving the editor, using user friendly piece of code recipes.
Update selected rows of a column in table ...
This recipe lets you to perform slightly more complex update operations. With more power comes more challenges. We will explore them in this notebook. If you wish to have finer control consider writing custom SQL queries in [raw query recipe](/notebooks/postgresql-python-raw-query/ "Raw query example").
Fill PostgreSQL database with AI using Python
Combining power of both SQL and AI we are going to fill out missing description columns in database using AI generated text.
Transfer data from database to a Google ...
Combining two very useful cookbooks of MLJAR studio: Postgresql and Google sheets integrations, it is possible to perform complex data science operations with just a few click. Abstracting all the annoyances away, letting you focus on the important work.