Do you or your organization use Google Sheets to store data? Do you ever wonder if you can use Google Sheets as a no-cost database? Do you think that you can integrate Google Sheets as a database to your web services without buying a traditional database? If the answer to the above questions is yes, then you have landed in the right place.
In this blog post, we aim to discuss how we can transform and use Google Sheets as a database. Here is the outline of what you’ll cover in this post.
- Introduction to Google Sheet
- Introduction to Databases
- Google Sheets as a Database
- Limitations of Using Google Sheets as a Database
Introduction to Google Sheets
Google Sheets is a product of Google that provides the capability of a spreadsheet over the cloud. Google Sheets is a lot like a spreadsheet app but on steroids. Due to its cloud platform, it provides more functionality compared to a standard spreadsheet.
Some of the key features of Google Sheets are –
- As it is web-based, you can access the data stored on Sheets from anywhere via the internet.
- All the leading device’s operating systems have an integrated app for the Google Sheets, which provide a seamless experience.
- It is free to use, and it comes bundled with your Gmail account. You don’t need to shell out an extra penny to use Google Sheets.
- Google Sheets are very similar to Microsoft Excel, and if you have worked with Excel, Google Sheets won’t be a challenge.
- Google Sheets allows you to download the plug-in, add-ons, and custom code to analyze data in spreadsheets effectively.
Introduction to Databases
A database is a collection of data in rows and columns. A database controls and organizes structured information of data with the help of a database management system (DBMS). A database allows you to easily access, monitor, organize, and manage the data.
A large number of databases use structured query language (SQL) for writing and querying data.
Some popular databases are –
- SQL Server
- MongoDB (NoSQL database)
Hevo, A Simpler Alternative to Integrate your Data for Analysis
Hevo offers a faster way to move data from databases, SaaS applications and 100+ other data sources into your data warehouse to be visualized in a BI tool. Hevo is fully automated and hence does not require you to code.Get Started with Hevo for Free
Check out some of the cool features of Hevo:
- Completely Automated: The Hevo platform can be set up in just a few minutes and requires minimal maintenance.
- Real-time Data Transfer: Hevo provides real-time data migration, so you can have analysis-ready data always.
- 100% Complete & Accurate Data Transfer: Hevo’s robust infrastructure ensures reliable data transfer with zero data loss.
- Scalable Infrastructure: Hevo has in-built integrations for 100+ sources that can help you scale your data infrastructure as required.
- 24/7 Live Support: The Hevo team is available round the clock to extend exceptional support to you through chat, email, and support call.
- Schema Management: Hevo takes away the tedious task of schema management & automatically detects schema of incoming data and maps it to the destination schema.
- Live Monitoring: Hevo allows you to monitor the data flow so you can check where your data is at a particular point in time.
Google Sheets as a Database
Google Sheets is a very advanced form of a spreadsheet, with many out of the box capabilities. Since it is a cloud-based app, you can also use them as a database for your small application or websites. You can easily discard the heavily priced DB’s such as MySQL, PostgreSQL, etc., and use Google Sheets to store the data and manage it in real-time. We are not saying that Google Sheets eliminates DB’s usage, but for smaller datasets, this can be considered an option.
Let’s see how you can use Google Sheets as a database.
- Google Cloud Platform Account
- Python 3.6 or later
- Basic understanding of programming languages and Excel data.
Enable Project in Google Cloud Console
- Go to the Google API Manager and create a new project.
- Add Google Drive API to the project. This is to allow access to spreadsheets stored on Google Drive.
- Generate the credential that will be used to authenticate the request that will be generated from the Python programme.
- Save the generated JSON key to your local machine, named as keys.json.
- Open the generated key to a text editor and copy the email address mentioned under a property called client_email.
- Create a sheet named “Tutorial” and add some data for a start.
- Share the access of your spreadsheet to the above email. This will allow access to the spreadsheet from API.
Connect to Spreadsheet via Python
- Open your favourite Python IDE and install the following packages –
pip install gspread oauth2client
- Create a file named googleSheetToPython.py and write the following lines of code.
#import library import gspread #Service client credential from oauth2client from oauth2client.service_account import ServiceAccountCredentials # Print nicely import pprint #Create scope scope = ['https://spreadsheets.google.com/feeds'] #create some credential using that scope and content of keys.json creds = ServiceAccountCredentials.from_json_keyfile_name(keys.json',scope) #create gspread authorize using that credential client = gspread.authorize(creds) #Now will can access our google sheets we call client.open on StartupName sheet = client.open('Tutorial').sheet1 pp = pprint.PrettyPrinter() #Access all of the record inside that result = sheet.get_all_record()
- Once the above credentials are setup, you can use the API to connect with your spreadsheet and perform CRUD (Create, Read, Update, Delete) operation on the Google Sheets.
- Below Python code, helps you to read the data from the Google Sheet –
result = sheet.row_values(5) #See individual row result_col = sheet.col.values(5) #See individual column result_cell = sheet.cell(5,2) # See particular cell pp = pprint.PrettyPrinter()
- Update the Values in Sheet
#update values sheet.update_cell(2,9,'500000') #Change value at cell(2,9) in the sheet result = sheet.cell(2,9) pp.pprint(result)
Limitations of Using Google Sheets as a Database
Google Sheets offer great functions for users to manage and analyze your data. However, it cannot eliminate the use of standard databases. Have a look at some of the constraints that you might face while using Google Sheets as a database.
- Not Fault Tolerant – Although the Google Sheets are available over the cloud, it is not as fault-tolerant as a standard database. If any user deletes the spreadsheet, the complete data will be lost. Whereas in the case of a standard database, the data gets replicated across multiple nodes and hence provides much more fault-tolerant systems.
- Storage Limitation – Google Sheets can only store up to 5 million records. At first go, this seems like a considerable number, but it is not enough for medium and large scale applications.
- Missing Database Features – Google Sheets as a database doesn’t provide database features like query, search, joins, consistency. There is no standard API where you can perform smooth joins. You always need to write complex programming to achieve these tasks
In this blog post, you have learned about Google Sheets and its features and also how you can use Google Sheets as a database. However, the Google Sheet cannot replace the standard database as it lacks certain functionalities. Extracting complex data from a diverse set of data sources such as Google Sheets can be a challenging task and this is where Hevo saves the day!Visit our Website to Explore Hevo
Hevo Data, a No-code Data Pipeline that helps you transfer data from a source of your choice in a fully automated and secure manner without having to write the code repeatedly. Hevo, with its secure integrations with 100+ sources & BI tools, allows you to export, load, transform, & enrich your data & make it analysis-ready in a jiffy.
If you are interested, you can try Hevo for free first. Sign Up for a 14-day free trial! You can now transfer data from sources like Google Sheets to your target destination for Free using Hevo! You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.
What do you think about using Google Sheets as a database? Share with us in the comments!