Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
An Object Relational Mapper (ORM) for the Google Sheets API. Provides a straightforward and intuitive model-based query interface, making it easy to interact with Google Sheets as if it were more like a database. Offers a fast and flexible way to get up and running with a Google Sheets database, for rapid prototyping and development in Python.
The gspread-models
package is an Object Relational Mapper (ORM) for the Google Sheets API. It provides a straightforward and intuitive model-based query interface, making it easy to interact with Google Sheets as if it were more like a database. This package offers a fast and flexible way to get up and running with a Google Sheets database, for rapid prototyping and development in Python.
Key Features:
Install the package from PyPI:
pip install gspread_models
Step 1: Bind the base model to your Google Sheets document and your credentials (see Authentication for more details):
from gspread_models.base import BaseModel
BaseModel.bind(
document_id="your-document-id",
credentials_filepath="/path/to/google-credentials.json"
)
Step 2: Define your own light-weight class that inherits from the base model:
class Book(BaseModel):
SHEET_NAME = "books"
COLUMNS = ["title", "author", "year"]
When defining your class, specify a SHEET_NAME
as well as a list of sheet-specific COLUMNS
.
Step 3: Setup a corresponding sheet for this model.
To support the example above, create a sheet called "books", and specify an initial row of column headers: "id", "title", "author", "year", and "created_at".
NOTE: In addition to the sheet-specific attributes ("title", "author", and "year"), the base model will manage metadata columns, including a unique identifier ("id") as well as a timestamp ("created_at").
Once you have your model class setup, you can utilize the Query Interface, to read and write data to the sheet.
Writing / appending records to the sheet:
Book.create_all([
{"title": "To Kill a Mockingbird", "author": "Harper Lee", "year": 1960},
{"title": "1984", "author": "George Orwell", "year": 1949},
{"title": "The Great Gatsby", "author": "F. Scott Fitzgerald", "year": 1925},
{"title": "The Catcher in the Rye", "author": "J.D. Salinger", "year": 1951},
{"title": "Pride and Prejudice", "author": "Jane Austen", "year": 1813},
])
Fetching all records from the sheet:
books = Book.all()
for book in books:
print(book.id, "|", book.title, "|", book.author)
#> 1 | To Kill a Mockingbird | Harper Lee
#> 2 | 1984 | George Orwell
#> 3 | The Great Gatsby | F. Scott Fitzgerald
#> 4 | The Catcher in the Rye | J.D. Salinger
#> 5 | Pride and Prejudice | Jane Austen
It is easy to create a pandas DataFrame from the returned objects by converting each to a dictionary:
from pandas import DataFrame
books_df = DataFrame([dict(book) for book in books])
books_df.head()
#> id title author year created_at
#> 1 To Kill a Mockingbird Harper Lee 1960 2024-05-22 21:36:25.582605+00:00
#> 2 1984 George Orwell 1949 2024-05-22 21:36:25.582738+00:00
#> 3 The Great Gatsby F. Scott Fitzgerald 1925 2024-05-22 21:36:25.582778+00:00
#> 4 The Catcher in the Rye J.D. Salinger 1951 2024-05-22 21:36:25.582813+00:00
#> 5 Pride and Prejudice Jane Austen 1813 2024-05-22 21:36:25.582846+00:00
For more details, see the usage documentation below:
Here are some examples that demonstrate the usage of gspread-models
within a variety of contexts:
If you use the gspread-models
package, you are encouraged to add your project to this list, by submitting a pull request or opening an issue.
Contributions welcome! Here are some reference guides to help you get started as a contributor or maintainer of this package:
This package is built on top of the awesome gspread
package.
FAQs
An Object Relational Mapper (ORM) for the Google Sheets API. Provides a straightforward and intuitive model-based query interface, making it easy to interact with Google Sheets as if it were more like a database. Offers a fast and flexible way to get up and running with a Google Sheets database, for rapid prototyping and development in Python.
We found that gspread-models demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.