Posts

Showing posts from June, 2021

What is a Database ?

Image
What is a Database? Definition, Meaning, Types, Example   What is Data? In simple words, data can be facts related to any object in consideration.  For example, your name, age, height, weight, etc. are some data related to you. A picture, image, file, pdf, etc. can also be considered data. What is Database? A database is a systematic collection of data.  They support electronic storage and manipulation of data.  Databases make data management easy. Types of Databases Here are some popular types of databases. Distributed databases: A distributed database is a type of database that has contributions from the common database and information captured by local computers.  In this type of database system, the data is not in one place and is distributed at various organizations. Relational databases: This type of database defines database relationships in the form of tables.  It is also called Relational DBMS, which is the most popular DBMS type in the market.  Database examples of the RDBM

SQLAlchemy Object Lifecycle

Image
 SQLAlchemy Object Lifecycle Recall We can insert new records into the database using SQLAlchemy by running. - person = Person(name='Amr') - db.session.add(person) - db.session.commit() which will build a transaction for inserting in a person instance in our model/table, and persist it to the database upon calling commit(). db.session: It isn't until we execute db.session() that we commit anything to the database. Every time we want to interact with the database we start a connection and end a connection when all of the interactions are done. Within that interaction session, We wound up creating transactions that we commit to the database every time that we want to commit work to the database.  So an important thing to keep in mind: - Proposed database changes are not immediately committed to the database once they're defined.  - Changes go through stages in order to provide the ability to "undo" a mistake.  - before committing it to a database. There are 4 st

GitHub repositories Every Developer Should Follow

Image
 GitHub repositories Every Developer Should Follow GitHub isn't just a version control service; it's a terrific content resource for all-things-development From free e-books and tutorials, to interview preparation material and awesome listicles, GitHub is that the go-to learning hub for Developers. If you're one among the developers who visit GitHub very often then greetings we've something for you, a set of GitHub repositories that you simply should mark star in your favorite repository list but it depends again on things that you simply want to find out or want to explore. I've compiled an inventory of the foremost valuable repositories, I'm willing to bet you haven't encountered most of them! 1. Awesome GitHub stars: 164k+ Awesome is, without a doubt, the most popular repo that curates all topics from software development to hardware to business. It has more than 123,000 stars on Github at this moment, and one could spend days (nights) browsing it

SQLAlchemy Model.query cheat-sheet

Image
SQLAlchemy  Model  query-cheat-sheet Query Methods Here are some useful query methods to get to know.  - Select records all() MyModel.query.all() Fetches all records from a table. Returns list of objects. first() MyModel.query.first() Fetches just the first result. Returns object or None. - Filtering filter_by() MyModel.query.filter_by(attr='some value') Similar to SELECT * from ... WHERE filter() Examples: MyModel.query.filter(MyOtherModel.some_attr='some value') OrderItem.query.filter(Product.id=3) Similar to filter_by , but instead, you specify attributes on a given Model.-- -- equals: query.filter(User.name == 'ed') -- not equals: query.filter(User.name != 'ed') LIKE : query.filter(User.name.like('%ed%')) ILIKE (case-insensitive LIKE): query.filter(User.name.ilike('%ed%')) IN: query.filter(User.name.in_(['ed', 'wendy', 'jack'])) NOT IN: query.filter(~User.name.in_(['ed', 'wendy', 'jack'

SQLAlchemy library for python

Image
 SQLAlchemy library for python  Introduction: What is SQLAlchemy? SQLAlchemy is a popular SQL toolkit and Object Relational Mapper.  It is written in Python and gives full power and flexibility of SQL to an application developer.  It is open-source and cross-platform software released under MIT license.  SQLAlchemy is famous for its object-relational mapper (ORM), using which classes can be mapped to the database, thereby allowing the object model and database schema to develop in a cleanly decoupled way from the beginning. It is one type of ORM library, AKA an Object-Relational Mapping library, which provides an interface for using object-oriented programming to interact with a database. Other ORM libraries that exist across other languages include popular choices like javascript libraries Sequelize and Bookshelf. js for NodeJS applications, the ruby library ActiveRecord, which is used inside Ruby on Rails, and CakePHP for applications written on PHP, amongst many other such ORMs. Not

What is a DBAPI ?

Image
 DB-API DB-API definition: - We will sometimes want to interact with our database and use its results in a specific programming language.   - To build web applications or data pipelines in a specific language like (Ruby, Python, Javascript, etc.). - That's where DBAPIs come in. A DB-API:  - A DB-API provides a standard for one programming language (like python) to talk to a relational database server. - Is a low-level library for writing SQL statements that connect to a database.  - Also known as database adapters. - Different DBAPIs exist for every server framework or language + database system. - Database adapters define a standard for using a database (with SQL) and using the results of database queries as input data in the given language. -- Turn a selected (SELECT * from some_table;) list of rows into an array of objects in Javascript for say a NodeJS adapter; or a list of tuples in Python for a Python adapter. Examples across languages and server frameworks: - For Ruby (e.g.

Connections and Sessions in TCP/IP

Image
 Connections and Sessions in TCP/IP TCP/IP is a connection-based protocol: - To start any communication a connection must be arranged. - Open a connection to start communications. - Close a connection to end communications.  - Meaning all communications between parties are arranged over a connection. - A connection is established before any data transmission begins. - Over TCP/IP , we'll always need to establish a connection between clients and servers in order to enable communications.  Moreover: Deliveries over the connection are error-checked, If packets arrive damaged or lost, then they are resent (known as retransmission). It's really important that we continually monitor what connections are opened and closed. between a recipient and sender because the more connection that we have open The more performance-based issues we may run into.  We will always need to establish a connection from a client application to a Postgres server Or MySQL server over TCP/IP in order to int