Saving a Profile

Saving a Profile

When you save() your Profile, the current or specified name will be used to create or update a save file in the location specified by local

From the Docs…

Profile.save(name=None, alert=True)[source]View on GitHub

Pickles and saves the Profile using the specified or currently set name.

Parameters
  • name (Optional[str]) – name to save the Profile under; replaces the current name

  • alert (bool) – set to True to print a message upon successful save

Return type

bool

InstaTweet.profile.Profile.local =True

Indicates if saves should be made locally (True) or on a remote database (False)

  • Local saves are made to the LOCAL_DIR, as pickle files

  • Remote saves are made to a database (via the db module) as pickle bytes

Important!!

You MUST configure the DATABASE_URL environment variable to save/load remotely

InstaTweet uses SQLAlchemy to create a DBConnection

  • Any SQLAlchemy-supported database is therefore also supported by InstaTweet

  • See the db module for more information

Example: Save a Profile

Note

You can specify a new name for the profile in the call to save()

from InstaTweet import Profile

>>> p = Profile('myProfile')
>>> p.save()

Saved Local Profile myProfile

>>> p.save('aProfile')
>>> print(p.name)

Saved Local Profile aProfile
aProfile

Profile names must be unique - you cannot save or create a profile if a profile_exists() with that name already

>>> q = Profile('myProfile')

FileExistsError: Local save file already exists for profile named "myProfile"
Please choose another name, load the profile, or delete the file.