Skip to content

Commit

Permalink
Merge pull request InstaPy#4270 from CharlesCCC/2019-4-5-Split-SQLite-DB
Browse files Browse the repository at this point in the history
 split sq lite db by username
  • Loading branch information
timgrossmann authored Apr 6, 2019
2 parents 44bc8e2 + 7df240f commit ecba309
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ The **goal** of this file is explaining to the users of our project the notable

_The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)_.


## [0.4.1] - 2019-04-06
### Added
- Support for split database with -sdb flag to avoid SQLite lock up

### Fixed
- "Failed to find login button" when trying to login (add KEYS.ENTER to submit login data)

Expand Down
21 changes: 20 additions & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
- [Disable Image Loading](#disable-image-loading)
- [Using Multiple Chromedrivers](#using-multiple-chromedrivers)
- [Changing DB or Chromedriver locations](#changing-db-or-chromedriver-locations)
- [Split SQLite DB by Username](#split-sqlite-by-username)
- [How to avoid _python_ & pip confusion](#how-to-avoid-python--pip-confusion)

---
Expand Down Expand Up @@ -2652,7 +2653,7 @@ To do this simply pass the `disable_image_load=True` parameter in the InstaPy co
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
disable_image_load=True,
disable_image_load=True,
multi_logs=True)
```

Expand All @@ -2674,6 +2675,24 @@ Settings.database_location = '/path/to/instapy.db'
Settings.chromedriver_location = '/path/to/chromedriver'
```

### Split SQLite by Username
If you experience issue with multiple accounts Instapy.db lockup. You can add the following flag

`-sdb` when running in Command line

or

To do this simply pass the `split_db=True` parameter in the InstaPy constructor like so:

```python
session = InstaPy(username=insta_username,
password=insta_password,
headless_browser=False,
split_db=True,
multi_logs=True)
```



### How to avoid _python_ & **pip** confusion

Expand Down
2 changes: 1 addition & 1 deletion instapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@


# __variables__ with double-quoted values will be available in setup.py
__version__ = "0.4.0"
__version__ = "0.4.1"

9 changes: 8 additions & 1 deletion instapy/instapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from .like_util import like_comment
from .login_util import login_user
from .settings import Settings
from .settings import localize_path
from .print_log_writer import log_follower_num
from .print_log_writer import log_following_num

Expand Down Expand Up @@ -105,7 +106,8 @@ def __init__(self,
disable_image_load=False,
bypass_suspicious_attempt=False,
bypass_with_mobile=False,
multi_logs=True):
multi_logs=True,
split_db=False):

cli_args = parse_cli_args()
username = cli_args.username or username
Expand All @@ -119,6 +121,7 @@ def __init__(self,
bypass_suspicious_attempt = (
cli_args.bypass_suspicious_attempt or bypass_suspicious_attempt)
bypass_with_mobile = cli_args.bypass_with_mobile or bypass_with_mobile
split_db = cli_args.split_db or split_db

Settings.InstaPy_is_running = True
# workspace must be ready before anything
Expand Down Expand Up @@ -147,6 +150,10 @@ def __init__(self,
self.password = password or os.environ.get('INSTA_PW')
Settings.profile["name"] = self.username

self.split_db = split_db
if self.split_db:
Settings.database_location = localize_path("db", "instapy_{}.db".format(self.username))

self.page_delay = page_delay
self.use_firefox = use_firefox
Settings.use_firefox = self.use_firefox
Expand Down
3 changes: 3 additions & 0 deletions instapy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,9 @@ def parse_cli_args():
parser.add_argument(
"-bwm", "--bypass-with-mobile", help="Bypass with mobile phone",
action="store_true", default=None)
parser.add_argument(
"-sdb", "--split-db", help="Split sqlite-db as instapy_{username}.db",
action="store_true", default=None)

""" Style below can convert strings into booleans:
```parser.add_argument("--is-debug",
Expand Down

0 comments on commit ecba309

Please sign in to comment.