url
stringlengths
53
56
repository_url
stringclasses
1 value
labels_url
stringlengths
67
70
comments_url
stringlengths
62
65
events_url
stringlengths
60
63
html_url
stringlengths
41
46
id
int64
450k
1.69B
node_id
stringlengths
18
32
number
int64
1
2.72k
title
stringlengths
1
209
user
dict
labels
list
state
stringclasses
1 value
locked
bool
2 classes
assignee
null
assignees
sequence
milestone
null
comments
sequence
created_at
timestamp[s]
updated_at
timestamp[s]
closed_at
timestamp[s]
author_association
stringclasses
3 values
active_lock_reason
stringclasses
2 values
body
stringlengths
0
104k
reactions
dict
timeline_url
stringlengths
62
65
performed_via_github_app
null
state_reason
stringclasses
2 values
draft
bool
2 classes
pull_request
dict
https://api.github.com/repos/coleifer/peewee/issues/1218
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1218/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1218/comments
https://api.github.com/repos/coleifer/peewee/issues/1218/events
https://github.com/coleifer/peewee/issues/1218
213,563,274
MDU6SXNzdWUyMTM1NjMyNzQ=
1,218
No sqlite3 causes issue on import of PaginatedQuery
{ "login": "savraj", "id": 387613, "node_id": "MDQ6VXNlcjM4NzYxMw==", "avatar_url": "https://avatars.githubusercontent.com/u/387613?v=4", "gravatar_id": "", "url": "https://api.github.com/users/savraj", "html_url": "https://github.com/savraj", "followers_url": "https://api.github.com/users/savraj/followers", "following_url": "https://api.github.com/users/savraj/following{/other_user}", "gists_url": "https://api.github.com/users/savraj/gists{/gist_id}", "starred_url": "https://api.github.com/users/savraj/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/savraj/subscriptions", "organizations_url": "https://api.github.com/users/savraj/orgs", "repos_url": "https://api.github.com/users/savraj/repos", "events_url": "https://api.github.com/users/savraj/events{/privacy}", "received_events_url": "https://api.github.com/users/savraj/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Aha, thanks! Should be fixed by f68ff7fb30a149fe9df8050b8001a1b4d3636bec", "This fix didn't work -- the error still happens because an AttributeError is the problem, the fix catches an ImportError.\r\n\r\nIf you look at the file `sqlite_ext.py`, line 54 `from peewee import sqlite3`\r\nThen looking at lines 155-165 in `peewee.py` `sqlite3` gets set to `None` if I don't have pysq3 or sqlite3, which I apparently don't have. :)\r\n\r\nAgain super appreciative of all the help and quick fixes. Thanks again.\r\n\r\n-s\r\n\r\n", "Is the traceback the same?\r\n\r\n```\r\nFTS_VER = sqlite3.sqlite_version_info[:3] >= (3, 7, 4) and 'FTS4' or 'FTS3'\r\nAttributeError: 'NoneType' object has no attribute 'sqlite_version_info'\r\n```", "Yes, I believe so, here's the full traceback (using a fresh pip install of 2.9.1):\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py\", line 240, in Handle\r\n handler = _config_handle.add_wsgi_middleware(self._LoadHandler())\r\n File \"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py\", line 299, in _LoadHandler\r\n handler, path, err = LoadObject(self._handler)\r\n File \"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py\", line 85, in LoadObject\r\n obj = __import__(path[0])\r\n File \"XXXX/main.py\", line 20, in <module>\r\n from controllers.XXXX import XXXX\r\n File \"XXXX/controllers/XXXX.py\", line 19, in <module>\r\n from playhouse.flask_utils import PaginatedQuery\r\n File \"XXXX/lib/playhouse/flask_utils.py\", line 12, in <module>\r\n from playhouse.db_url import connect as db_url_connect\r\n File \"XXXX/lib/playhouse/db_url.py\", line 7, in <module>\r\n from playhouse.pool import PooledMySQLDatabase\r\n File \"XXXX/lib/playhouse/pool.py\", line 279, in <module>\r\n from playhouse.sqlite_ext import SqliteExtDatabase\r\n File \"XXXX/lib/playhouse/sqlite_ext.py\", line 70, in <module>\r\n FTS_VER = sqlite3.sqlite_version_info[:3] >= (3, 7, 4) and 'FTS4' or 'FTS3'\r\nAttributeError: 'NoneType' object has no attribute 'sqlite_version_info'\r\n```", "Could you try the latest commit, fc84b65ff3a02eba05ccf63aead2de38412ac9c3 and let me know how it works? Sorry for the bad fix!", "Hi -- just checking in. This fix hasn't made it in to the latest version yet, afaict, on install from pip. I do see it is in the master repo, though.", "It should be in 2.9.2.", "got it! thanks!\n\nOn Thu, Apr 13, 2017 at 8:34 PM, Charles Leifer <[email protected]>\nwrote:\n\n> It should be in 2.9.2.\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/coleifer/peewee/issues/1218#issuecomment-294055750>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AAXqHY27cuB3eDVczU2JPKgVRlJ7niueks5rvr8mgaJpZM4MaWl5>\n> .\n>\n\n\n\n-- \nSavraj Singh\nFounder, Wattvision.com\n609.540.2204 • twitter/gtalk/skype: savraj\[email protected]\n", "Still facing the sqlite3 issue, even though we are using peewee==2.10.1. Please advice at the earliest. Thank you.\r\n\r\nError Stack Trace -\r\n'NoneType' object has no attribute 'sqlite_version_info': AttributeError\r\nTraceback (most recent call last):\r\nFile \"/var/task/handler.py\", line 511, in lambda_handler\r\nreturn LambdaHandler.lambda_handler(event, context)\r\nFile \"/var/task/handler.py\", line 242, in lambda_handler\r\nreturn handler.handler(event, context)\r\nFile \"/var/task/handler.py\", line 335, in handler\r\napp_function = self.import_module_and_get_function(whole_function)\r\nFile \"/var/task/handler.py\", line 233, in import_module_and_get_function\r\napp_module = importlib.import_module(module)\r\nFile \"/var/lang/lib/python3.6/importlib/init.py\", line 126, in import_module\r\nreturn _bootstrap._gcd_import(name[level:], package, level)\r\nFile \"\", line 978, in _gcd_import\r\nFile \"\", line 961, in _find_and_load\r\nFile \"\", line 950, in _find_and_load_unlocked\r\nFile \"\", line 655, in _load_unlocked\r\nFile \"\", line 678, in exec_module\r\nFile \"\", line 205, in _call_with_frames_removed\r\nFile \"/var/task/schedular.py\", line 16, in \r\nimport models_postgres as models\r\nFile \"/var/task/models_postgres.py\", line 4, in \r\nfrom playhouse.db_url import connect\r\nFile \"/var/task/playhouse/db_url.py\", line 118, in \r\nfrom playhouse.berkeleydb import BerkeleyDatabase\r\nFile \"/var/task/playhouse/berkeleydb.py\", line 10, in \r\nsqlite3_lib_version = sqlite3.sqlite_version_info\r\nAttributeError: 'NoneType' object has no attribute 'sqlite_version_info'", "8ba62478f7ce4fc3890fad0d1c42e851a382bdd4", "Thanks for the traceback, that helped me narrow it down." ]
2017-03-11T22:13:43
2017-10-08T16:22:31
2017-03-16T03:16:57
NONE
null
I use MySQL and don't need sqlite3. `from playhouse.flask_utils import PaginatedQuery` gives me this error: ``` FTS_VER = sqlite3.sqlite_version_info[:3] >= (3, 7, 4) and 'FTS4' or 'FTS3' AttributeError: 'NoneType' object has no attribute 'sqlite_version_info' ``` [line that causes error](https://github.com/coleifer/peewee/blob/f3795767f7b46c8b5335ea0257df2a1d269fc85b/playhouse/sqlite_ext.py#L70) I'm in the google app engine development environment, so I believe sqlite3 gets set to `None` when the `ImportError` is caught. My hacky fix is an if/else setting `FTS_VER` to `None` if there's no `sqlite3`.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1218/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1218/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1217
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1217/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1217/comments
https://api.github.com/repos/coleifer/peewee/issues/1217/events
https://github.com/coleifer/peewee/issues/1217
213,455,933
MDU6SXNzdWUyMTM0NTU5MzM=
1,217
ForeignKey circular suggestion
{ "login": "paulocheque", "id": 94350, "node_id": "MDQ6VXNlcjk0MzUw", "avatar_url": "https://avatars.githubusercontent.com/u/94350?v=4", "gravatar_id": "", "url": "https://api.github.com/users/paulocheque", "html_url": "https://github.com/paulocheque", "followers_url": "https://api.github.com/users/paulocheque/followers", "following_url": "https://api.github.com/users/paulocheque/following{/other_user}", "gists_url": "https://api.github.com/users/paulocheque/gists{/gist_id}", "starred_url": "https://api.github.com/users/paulocheque/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/paulocheque/subscriptions", "organizations_url": "https://api.github.com/users/paulocheque/orgs", "repos_url": "https://api.github.com/users/paulocheque/repos", "events_url": "https://api.github.com/users/paulocheque/events{/privacy}", "received_events_url": "https://api.github.com/users/paulocheque/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-03-10T21:25:06
2017-03-12T15:06:20
2017-03-12T15:06:20
NONE
null
Hi there, suggestion: http://docs.peewee-orm.com/en/latest/peewee/models.html?highlight=NameError#circular-foreign-key-dependencies It could do like Django ORM: ForeignKey('path.to.Model')
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1217/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1217/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1216
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1216/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1216/comments
https://api.github.com/repos/coleifer/peewee/issues/1216/events
https://github.com/coleifer/peewee/issues/1216
213,244,462
MDU6SXNzdWUyMTMyNDQ0NjI=
1,216
Test failure in 2.9.0 release
{ "login": "felixonmars", "id": 1006477, "node_id": "MDQ6VXNlcjEwMDY0Nzc=", "avatar_url": "https://avatars.githubusercontent.com/u/1006477?v=4", "gravatar_id": "", "url": "https://api.github.com/users/felixonmars", "html_url": "https://github.com/felixonmars", "followers_url": "https://api.github.com/users/felixonmars/followers", "following_url": "https://api.github.com/users/felixonmars/following{/other_user}", "gists_url": "https://api.github.com/users/felixonmars/gists{/gist_id}", "starred_url": "https://api.github.com/users/felixonmars/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/felixonmars/subscriptions", "organizations_url": "https://api.github.com/users/felixonmars/orgs", "repos_url": "https://api.github.com/users/felixonmars/repos", "events_url": "https://api.github.com/users/felixonmars/events{/privacy}", "received_events_url": "https://api.github.com/users/felixonmars/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yeah, it's fixed." ]
2017-03-10T04:56:32
2017-03-10T21:46:07
2017-03-10T21:46:07
CONTRIBUTOR
null
``` ====================================================================== ERROR: test_create_or_get (playhouse.tests.test_gfk.GFKTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/build/python-peewee/src/peewee/playhouse/tests/test_gfk.py", line 123, in test_create_or_get self._test_get_create(Tag.create_or_get) AttributeError: type object 'Tag' has no attribute 'create_or_get' ---------------------------------------------------------------------- Ran 598 tests in 5.246s FAILED (errors=1) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1216/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1216/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1215
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1215/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1215/comments
https://api.github.com/repos/coleifer/peewee/issues/1215/events
https://github.com/coleifer/peewee/pull/1215
213,135,959
MDExOlB1bGxSZXF1ZXN0MTA5OTg0ODE1
1,215
Add most recent Python versions in Travis CI
{ "login": "SylvainDe", "id": 1242285, "node_id": "MDQ6VXNlcjEyNDIyODU=", "avatar_url": "https://avatars.githubusercontent.com/u/1242285?v=4", "gravatar_id": "", "url": "https://api.github.com/users/SylvainDe", "html_url": "https://github.com/SylvainDe", "followers_url": "https://api.github.com/users/SylvainDe/followers", "following_url": "https://api.github.com/users/SylvainDe/following{/other_user}", "gists_url": "https://api.github.com/users/SylvainDe/gists{/gist_id}", "starred_url": "https://api.github.com/users/SylvainDe/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/SylvainDe/subscriptions", "organizations_url": "https://api.github.com/users/SylvainDe/orgs", "repos_url": "https://api.github.com/users/SylvainDe/repos", "events_url": "https://api.github.com/users/SylvainDe/events{/privacy}", "received_events_url": "https://api.github.com/users/SylvainDe/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-03-09T19:14:05
2017-03-23T18:10:59
2017-03-23T18:10:59
NONE
null
Add more recent Python versions including development branches and nightly build. The motivation came from reading brettcannon's article : https://snarky.ca/how-to-use-your-project-travis-to-help-test-python-itself/ . Trying to activate the newest Python versions on CI jobs is in most case a win-win situation: if everything works fine, there is nothing to worry about. If an issue is spotted, it is good to know about it to fix it on your side or to open a bug on CPython ( https://bugs.python.org/ ). Also, if a failures is spotted, you can use the allow_failures option in your matrix build (more information about this in the link above). Also, nightly and 3.7-dev may be a bit too recent/unstable so I can remove then if need be. More information about how this PR happened : https://github.com/SylvainDe/CIthon . More information about the various Python versions available on Travis : https://docs.travis-ci.com/user/languages/python/ . More information about the Python 3.6 version schedule : https://www.python.org/dev/peps/pep-0494/ . More information about the Python 3.7 version schedule : https://www.python.org/dev/peps/pep-0537/ .
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1215/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1215/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1215", "html_url": "https://github.com/coleifer/peewee/pull/1215", "diff_url": "https://github.com/coleifer/peewee/pull/1215.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1215.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1214
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1214/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1214/comments
https://api.github.com/repos/coleifer/peewee/issues/1214/events
https://github.com/coleifer/peewee/issues/1214
212,901,212
MDU6SXNzdWUyMTI5MDEyMTI=
1,214
Hack: Peewee Tables to Pandas DataFrames
{ "login": "NJDFan", "id": 8527880, "node_id": "MDQ6VXNlcjg1Mjc4ODA=", "avatar_url": "https://avatars.githubusercontent.com/u/8527880?v=4", "gravatar_id": "", "url": "https://api.github.com/users/NJDFan", "html_url": "https://github.com/NJDFan", "followers_url": "https://api.github.com/users/NJDFan/followers", "following_url": "https://api.github.com/users/NJDFan/following{/other_user}", "gists_url": "https://api.github.com/users/NJDFan/gists{/gist_id}", "starred_url": "https://api.github.com/users/NJDFan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/NJDFan/subscriptions", "organizations_url": "https://api.github.com/users/NJDFan/orgs", "repos_url": "https://api.github.com/users/NJDFan/repos", "events_url": "https://api.github.com/users/NJDFan/events{/privacy}", "received_events_url": "https://api.github.com/users/NJDFan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "There is a mechanism to inspect fields, MyModelClass._meta.fields. Check it out -- should be what you need." ]
2017-03-09T00:37:27
2017-03-09T15:37:46
2017-03-09T15:37:46
NONE
null
I find SQL tables excellent for experimental data collection (often multi-day processes) and godawful for examination/analysis. So, I figured out this trick and figured I'd send it to you in case anyone else out there finds it useful. Note: it would definitely be cleaner if there was a mechanism to introspect fields. ```python import pandas as pd import peewee def peewee_to_df(table): fields = [fld for fld in dir(table) if isinstance(getattr(table, fld), peewee.Field)] data = list(table.select(*[getattr(table, fld) for fld in fields]).tuples()) df = pd.DataFrame.from_records(data, columns=fields) if 'id' in fields: df.set_index('id', inplace=True) return df ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1214/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1214/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1213
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1213/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1213/comments
https://api.github.com/repos/coleifer/peewee/issues/1213/events
https://github.com/coleifer/peewee/issues/1213
212,876,833
MDU6SXNzdWUyMTI4NzY4MzM=
1,213
Update cache without table name throws error
{ "login": "erichaydel", "id": 6462853, "node_id": "MDQ6VXNlcjY0NjI4NTM=", "avatar_url": "https://avatars.githubusercontent.com/u/6462853?v=4", "gravatar_id": "", "url": "https://api.github.com/users/erichaydel", "html_url": "https://github.com/erichaydel", "followers_url": "https://api.github.com/users/erichaydel/followers", "following_url": "https://api.github.com/users/erichaydel/following{/other_user}", "gists_url": "https://api.github.com/users/erichaydel/gists{/gist_id}", "starred_url": "https://api.github.com/users/erichaydel/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/erichaydel/subscriptions", "organizations_url": "https://api.github.com/users/erichaydel/orgs", "repos_url": "https://api.github.com/users/erichaydel/repos", "events_url": "https://api.github.com/users/erichaydel/events{/privacy}", "received_events_url": "https://api.github.com/users/erichaydel/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-03-08T22:30:01
2017-03-18T22:04:38
2017-03-18T22:04:38
NONE
null
In line 82 of dataset, https://github.com/coleifer/peewee/blob/master/playhouse/dataset.py#L82, table_names is calculated as a list inline. However, if no table name is set (want to update all), dependencies is set to None a couple of lines earlier. This will throw the error "NoneType is not iterable".
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1213/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1213/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1212
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1212/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1212/comments
https://api.github.com/repos/coleifer/peewee/issues/1212/events
https://github.com/coleifer/peewee/issues/1212
212,857,060
MDU6SXNzdWUyMTI4NTcwNjA=
1,212
Changelog?
{ "login": "MinchinWeb", "id": 1548809, "node_id": "MDQ6VXNlcjE1NDg4MDk=", "avatar_url": "https://avatars.githubusercontent.com/u/1548809?v=4", "gravatar_id": "", "url": "https://api.github.com/users/MinchinWeb", "html_url": "https://github.com/MinchinWeb", "followers_url": "https://api.github.com/users/MinchinWeb/followers", "following_url": "https://api.github.com/users/MinchinWeb/following{/other_user}", "gists_url": "https://api.github.com/users/MinchinWeb/gists{/gist_id}", "starred_url": "https://api.github.com/users/MinchinWeb/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/MinchinWeb/subscriptions", "organizations_url": "https://api.github.com/users/MinchinWeb/orgs", "repos_url": "https://api.github.com/users/MinchinWeb/repos", "events_url": "https://api.github.com/users/MinchinWeb/events{/privacy}", "received_events_url": "https://api.github.com/users/MinchinWeb/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "https://github.com/coleifer/peewee/blob/master/CHANGELOG.md", "Thank you!!" ]
2017-03-08T21:07:59
2017-03-09T21:10:31
2017-03-08T21:12:57
NONE
null
I can't seem to find the changelog for Peewee. Can you point me to it? If one doesn't exist yet, please let this serve as a humble request for one.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1212/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1212/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1211
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1211/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1211/comments
https://api.github.com/repos/coleifer/peewee/issues/1211/events
https://github.com/coleifer/peewee/issues/1211
212,814,276
MDU6SXNzdWUyMTI4MTQyNzY=
1,211
playhouse.flask_utils.FlaskDB and testing
{ "login": "gkrnours", "id": 61116, "node_id": "MDQ6VXNlcjYxMTE2", "avatar_url": "https://avatars.githubusercontent.com/u/61116?v=4", "gravatar_id": "", "url": "https://api.github.com/users/gkrnours", "html_url": "https://github.com/gkrnours", "followers_url": "https://api.github.com/users/gkrnours/followers", "following_url": "https://api.github.com/users/gkrnours/following{/other_user}", "gists_url": "https://api.github.com/users/gkrnours/gists{/gist_id}", "starred_url": "https://api.github.com/users/gkrnours/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/gkrnours/subscriptions", "organizations_url": "https://api.github.com/users/gkrnours/orgs", "repos_url": "https://api.github.com/users/gkrnours/repos", "events_url": "https://api.github.com/users/gkrnours/events{/privacy}", "received_events_url": "https://api.github.com/users/gkrnours/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Welllll... based on your issue description, there's not really anything I can go off of besides that it didn't work for your tests. Can you provide me with something I can reproduce? Some code that exemplifies the issue? What \"not working\" actually means?", "I wrote a small gist with a small flask app using FlaskDB (30 lines) and a test:\r\nhttps://gist.github.com/gkrnours/f2fa9609617c27dd7dc621eff8eb898e\r\nThe test try to follow http://flask.pocoo.org/docs/0.12/testing/#testing\r\n\r\nThe app run as excepted but the test fail when using the test_client with peewee.OperationalError: Connection already open.\r\nMaybe I'm doing something wrong.\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"test.py\", line 22, in test_client\r\n self.app.get(\"/\")\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/werkzeug/test.py\", line 778, in get\r\n return self.open(*args, **kw)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/testing.py\", line 127, in open\r\n follow_redirects=follow_redirects)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/werkzeug/test.py\", line 751, in open\r\n response = self.run_wsgi_app(environ, buffered=buffered)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/werkzeug/test.py\", line 668, in run_wsgi_app\r\n rv = run_wsgi_app(self.application, environ, buffered=buffered)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/werkzeug/test.py\", line 871, in run_wsgi_app\r\n app_rv = app(environ, start_response)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1994, in __call__\r\n return self.wsgi_app(environ, start_response)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1985, in wsgi_app\r\n response = self.handle_exception(e)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1540, in handle_exception\r\n reraise(exc_type, exc_value, tb)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/_compat.py\", line 33, in reraise\r\n raise value\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1982, in wsgi_app\r\n response = self.full_dispatch_request()\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1614, in full_dispatch_request\r\n rv = self.handle_user_exception(e)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1517, in handle_user_exception\r\n reraise(exc_type, exc_value, tb)\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/_compat.py\", line 33, in reraise\r\n raise value\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1610, in full_dispatch_request\r\n rv = self.preprocess_request()\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/flask/app.py\", line 1831, in preprocess_request\r\n rv = func()\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/playhouse/flask_utils.py\", line 171, in connect_db\r\n self.database.connect()\r\n File \"/home/gkr/work/web/peewee-flask/nv/lib/python3.4/site-packages/peewee.py\", line 3652, in connect\r\n raise OperationalError('Connection already open')\r\npeewee.OperationalError: Connection already open\r\n```\r\n", "The error seems pretty clear to me. Are you opening a database connection (even implicitly, to create tables, for instance) anywhere in your tests? If so, be sure to close it. The FlaskDB helper binds handlers to the request setup/teardown cycle in which it connects/closes, respectively. If there's already a connection open in the given thread in which the request is run, then you'll see the above error. It's not a bug, it's a sign to you that you've left a connection dangling somewhere.", "I do not leave open connection. FlaskDB do when used with the Flask test_client.\r\nThe only time I open the database is for creating the table and I close it 2 line after opening it.\r\n\r\nThat's the whole point of the issue, I had to choose between FlaskDB and testing my application.", "Sorry, reopening to look into this more.", "I see the issue. The problem is that you're initializing the database once for every test-case. Because there are two test-cases, the database gets \"init_app()\" called twice. Inside `db.init_app()`, handlers are bound to the app's `before_request()` and `request_teardown()` hooks. Inside the `before_request()` hook, the conn is opened.\r\n\r\nThe problem can be resolved by only calling `app.init_db()` *once*. Your app is essentially a singleton object so it maintains its state from run to run.\r\n\r\nNot a bug in peewee, but in the way you're setting up your tests. Hope that makes sense.", "The explanation make sense yes." ]
2017-03-08T18:18:06
2017-04-08T13:22:36
2017-04-07T23:54:06
NONE
null
I tried to write some test for a basic app using [playhouse.flask_utils.FlaskDB](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#database-wrapper) and sqlite but I couldn't manage to make it work with [flask.Flask.test_client](http://flask.pocoo.org/docs/0.12/api/#flask.Flask.test_client). This is a tool coming with Flask allowing to make easily request against the app. Some documentation on the subject would be welcome as test are an important part of an application. I spend a couple of day on the problem then I moved the use bare peewee, without FlaskDB.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1211/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1211/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1210
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1210/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1210/comments
https://api.github.com/repos/coleifer/peewee/issues/1210/events
https://github.com/coleifer/peewee/issues/1210
212,620,438
MDU6SXNzdWUyMTI2MjA0Mzg=
1,210
PostgresqlExtDatabase last_insert_id w/ autocommit=True issues
{ "login": "skewty", "id": 9087223, "node_id": "MDQ6VXNlcjkwODcyMjM=", "avatar_url": "https://avatars.githubusercontent.com/u/9087223?v=4", "gravatar_id": "", "url": "https://api.github.com/users/skewty", "html_url": "https://github.com/skewty", "followers_url": "https://api.github.com/users/skewty/followers", "following_url": "https://api.github.com/users/skewty/following{/other_user}", "gists_url": "https://api.github.com/users/skewty/gists{/gist_id}", "starred_url": "https://api.github.com/users/skewty/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/skewty/subscriptions", "organizations_url": "https://api.github.com/users/skewty/orgs", "repos_url": "https://api.github.com/users/skewty/repos", "events_url": "https://api.github.com/users/skewty/events{/privacy}", "received_events_url": "https://api.github.com/users/skewty/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It looks like the `id` field is not unique. Since I don't have your model definition, I'm not sure how you've got `id` defined, but that seems to be the issue. If it's the primary key, it needs to be unique.\r\n\r\nThe reason the calls to save() don't work, I'm guessing, is because you're using a non-auto-incrementing primary key. When this is the case, you must call save() with force_insert=True in order to create a new record.", "Here are the models:\r\n```\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = get_database()\r\n\r\n\r\nclass Feature(BaseModel):\r\n class Meta:\r\n db_table = \"feature\"\r\n identifier = CharField(max_length=MAX_IDENTIFIER_LENGTH, null=False)\r\n json_data = JSONField(default={})\r\n filter = ForeignKeyField(Filter)\r\n icon_group = ForeignKeyField(IconGroup)\r\n icon_state = ForeignKeyField(IconState)\r\n tile_set = ForeignKeyField(TileSet)\r\n longitude = DoubleField()\r\n lattitude = DoubleField()\r\n zone_name = CharField(max_length=MAX_ZONE_NAME_LENGTH, null=True)\r\n battery_percentage = IntegerField(null=True)\r\n last_updated = DateTimeField()\r\n```\r\n\r\nThe table is created in code by:\r\n```\r\n model_classes = [getattr(sys.modules[__name__], model_name) for model_name in MODEL_NAMES]\r\n database.drop_tables(model_classes, safe=True, cascade=True)\r\n database.create_tables(model_classes)\r\n```\r\nand after it is created the id field is:\r\n```\r\nid INTEGER default nextval('feature_id_seq'::regclass)\r\n```", "I thought we were talking about the `Filter` model? could you include that models' definition?", "Oops, sorry. I totally included the wrong model..\r\n\r\n```\r\nclass Filter(BaseModel):\r\n class Meta:\r\n db_table = \"filter\"\r\n\r\n gui_label = CharField(max_length=MAX_FILTER_NAME_LENGTH, null=False)\r\n supress_alarms = BooleanField(default=False)\r\n json_data_format = JSONField(null=True, default={})\r\n icon_group = ForeignKeyField(IconGroup, null=False)\r\n```\r\n\r\nThe id field is identical:\r\n```\r\nid INTEGER default nextval('filter_id_seq'::regclass)\r\n```\r\n", "Thank you! Awesome, so you're using the default \"id\" field definition, which is an auto-incrementing primary key. Yet in your code examples, you're setting the \"id\" to a particular value. Is there a reason for that?\r\n\r\n```python\r\nFilter.insert(\r\n id=DEFAULT_FILTER_ALARMS_ID,\r\n```\r\n\r\nCheck out the docs in this and the following related sections for more info: http://docs.peewee-orm.com/en/latest/peewee/models.html#non-integer-primary-keys-composite-keys-and-other-tricks", "I need to ensure particular id values, because there are constants in the code that will reference it.\r\nThis code is all extracted from a database init script. \r\n\r\nIs including the id field causing the issue?\r\n\r\nI guess I could throw an exception if the value returned from `Model.insert().execute()` doesn't match the expected id.", "Eww. Why not add another column that contains a human-readable, non opaque value and key off of that?", "The linked documentation (thanks, it is great) seems to mention `Model.save()` only. My failed examples were not using `Model.save()` and the id numbers being specified were matching those that autoincrement would have provided. \r\n\r\nIs `Filter._meta.auto_increment = False` required if I am trying to use `Model.insert()` with a value specified for an autoincrementing field set to a value that would match the value returned?\r\n\r\n```\r\nFilter.insert(id=4, ...).execute()\r\nFilter.insert(id=24, ...).execute()\r\nFilter.insert(id=64, ...).execute()\r\n```\r\nworks without error without using `Filter._meta.auto_increment = False` first\r\n\r\nIt would seem to me something isn't quite right with `Model.insert()` because it seems to bypass the `Model._meta.auto_increment` value.", "FYI\r\n\r\n```\r\n if DEFAULT_FILTER_ALARMS_ID != Filter.insert(\r\n gui_label=DEFAULT_FILTER_ALARMS_LABEL,\r\n supress_alarms=False,\r\n icon_group=IconGroup.Value.default,\r\n ).execute():\r\n raise ValueError(\"Filter id for {} is incorrect\".format(DEFAULT_FILTER_ALARMS_LABEL))\r\n```\r\n\r\nworks without causing exception in subsequent code.", "If you truly wish to manually specify the IDs, then they shouldn't be auto-incrementing. You can change this by specifying\r\n\r\nid = IntegerField (primary_key=True)\r\n\r\nHonestly I think you're going down the wrong path by specifying the id like this. Just add a column that contains a human-readable key and use that as your constant value.", "I will take your advice and change the field type to: `id = IntegerField (primary_key=True)`\r\n\r\nThank you so much for the prompt responses!" ]
2017-03-08T02:31:04
2017-03-08T19:05:57
2017-03-08T18:37:49
NONE
null
I think I may be fighting the below two issues (possible regression?): issue #353 issue #356 I just upgraded to peewee 2.90 to ensure it wasn't a regression in the build I was using. If I use `Model.insert().execute()` for the first Filter insert then the subsequent code will never work without exception. I need to use the `Model().save()` method for the first Filter if I want the subsequent code to work without exception. If I use the `Model().save()` method for the first Filter then I can use either the `Model().save()` method or the `Model.insert().execute()` method for the subsequent section without exception. First Filter creation is: ``` if Filter.select().count() == 0: # Filter( # # id=DEFAULT_FILTER_ALARMS_ID, # if you put this, it won't save # gui_label=DEFAULT_FILTER_ALARMS_LABEL, # supress_alarms=False, # icon_group=IconGroup.Value.default, # ).save() Filter.insert( id=DEFAULT_FILTER_ALARMS_ID, gui_label=DEFAULT_FILTER_ALARMS_LABEL, supress_alarms=False, icon_group=IconGroup.Value.default, ).execute() ``` The subsequent code a bit later is: ``` for filter_name in ['Staff', 'Patients', 'Media carts', 'Computers on wheels', 'Laptop computers', 'IV pumps', 'PCU pumps', 'SCD pumps', 'Stretchers', 'Beds', 'Wheelchairs', 'Comodes']: # Filter( # icon_group=icon_group_sonitor.id, # gui_label=filter_name, # json_data_format={ # 'owner': {'html_type': 'text'}, # 'tag#': {'html_type': 'text'}, # }, # ).save() Filter.insert( icon_group=icon_group_sonitor.id, gui_label=filter_name, json_data_format={ 'owner': {'html_type': 'text'}, 'tag#': {'html_type': 'text'}, } ).execute() ``` The `PostgresqlExtDatabase` is shared by both code snippets. The exception stack trace is: ``` ... File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 3499, in execute cursor = self._execute() File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 2885, in _execute return self.database.execute_sql(sql, params, self.require_commit) File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\playhouse\postgres_ext.py", line 386, in execute_sql self.commit() File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 3571, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 135, in reraise raise value.with_traceback(tb) File "C:\Users\Scott\AppData\Local\Programs\Python\Python35-32\lib\site-packages\playhouse\postgres_ext.py", line 379, in execute_sql cursor.execute(sql, params or ()) peewee.IntegrityError: duplicate key value violates unique constraint "filter_pkey" DETAIL: Key (id)=(1) already exists. ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1210/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1210/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1209
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1209/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1209/comments
https://api.github.com/repos/coleifer/peewee/issues/1209/events
https://github.com/coleifer/peewee/pull/1209
212,306,835
MDExOlB1bGxSZXF1ZXN0MTA5MzkwMzMy
1,209
Enhence migrate add and drop foreign keys in mysql
{ "login": "EenTang", "id": 16539902, "node_id": "MDQ6VXNlcjE2NTM5OTAy", "avatar_url": "https://avatars.githubusercontent.com/u/16539902?v=4", "gravatar_id": "", "url": "https://api.github.com/users/EenTang", "html_url": "https://github.com/EenTang", "followers_url": "https://api.github.com/users/EenTang/followers", "following_url": "https://api.github.com/users/EenTang/following{/other_user}", "gists_url": "https://api.github.com/users/EenTang/gists{/gist_id}", "starred_url": "https://api.github.com/users/EenTang/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/EenTang/subscriptions", "organizations_url": "https://api.github.com/users/EenTang/orgs", "repos_url": "https://api.github.com/users/EenTang/repos", "events_url": "https://api.github.com/users/EenTang/events{/privacy}", "received_events_url": "https://api.github.com/users/EenTang/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-03-07T01:54:10
2018-01-31T12:41:07
2018-01-31T12:41:07
NONE
null
There are some bugs in migrate when add or drop foreign keys in mysql. So I write this to fixed it.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1209/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1209/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1209", "html_url": "https://github.com/coleifer/peewee/pull/1209", "diff_url": "https://github.com/coleifer/peewee/pull/1209.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1209.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1208
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1208/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1208/comments
https://api.github.com/repos/coleifer/peewee/issues/1208/events
https://github.com/coleifer/peewee/issues/1208
212,038,803
MDU6SXNzdWUyMTIwMzg4MDM=
1,208
bug on rollback? (peewee==2.8.7)
{ "login": "paulocheque", "id": 94350, "node_id": "MDQ6VXNlcjk0MzUw", "avatar_url": "https://avatars.githubusercontent.com/u/94350?v=4", "gravatar_id": "", "url": "https://api.github.com/users/paulocheque", "html_url": "https://github.com/paulocheque", "followers_url": "https://api.github.com/users/paulocheque/followers", "following_url": "https://api.github.com/users/paulocheque/following{/other_user}", "gists_url": "https://api.github.com/users/paulocheque/gists{/gist_id}", "starred_url": "https://api.github.com/users/paulocheque/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/paulocheque/subscriptions", "organizations_url": "https://api.github.com/users/paulocheque/orgs", "repos_url": "https://api.github.com/users/paulocheque/repos", "events_url": "https://api.github.com/users/paulocheque/events{/privacy}", "received_events_url": "https://api.github.com/users/paulocheque/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "If I'm understanding your \"example\" code, then the following is equivalent:\r\n\r\n```pythondb = SqliteDatabase(':memory:')\r\n\r\nclass Register(Model):\r\n value = IntegerField()\r\n class Meta:\r\n database = db\r\n\r\ndb.create_tables([Register])\r\n\r\nwith db.transaction() as txn:\r\n Register.create(value=1)\r\n Register.create(value=2)\r\n txn.rollback()\r\n txn.commit()\r\n\r\nprint Register.select().count()\r\n```\r\n\r\nWhen I run that script, the output is `0` as I'd expect.", "Did you test with PostgresqlExtDatabase (Postgres 9.6)? With Python 3.6? With peewee 2.8.7?\r\n\r\nFor me the output is `2`.\r\n\r\n```\r\n from playhouse.postgres_ext import PostgresqlExtDatabase\r\n db = PostgresqlExtDatabase()\r\n db.connect()\r\n with db.transaction() as txn:\r\n # User(email='[email protected]').save()\r\n # User(email='[email protected]').save()\r\n User.create(email='[email protected]')\r\n User.create(email='[email protected]')\r\n txn.rollback()\r\n txn.commit()\r\n print(User.select().count())\r\n db.close()\r\n\r\n```\r\n\r\nAny ideas?", "I did not test with Python 3. Maybe you can test with Python 2 and see if that works for you?\r\n\r\nI re-ran the script and I'm still seeing 0 as the output:\r\n\r\n```python\r\nfrom peewee import *\r\nfrom playhouse.postgres_ext import PostgresqlExtDatabase\r\n\r\n\r\n#db = SqliteDatabase(':memory:')\r\ndb = PostgresqlExtDatabase('peewee_test')\r\n\r\nclass Register(Model):\r\n value = IntegerField()\r\n class Meta:\r\n database = db\r\n\r\ndb.create_tables([Register])\r\n\r\nwith db.transaction() as txn:\r\n Register.create(value=1)\r\n Register.create(value=2)\r\n txn.rollback()\r\n txn.commit()\r\n\r\nprint(Register.select().count())\r\ndb.drop_tables([Register])\r\n```\r\n\r\nAre you sure you don't have users in the db you're counting? Maybe drop then re-create the table?", "I tested here a clean example with Py2 and Py3 and it is working. Well, no idea what is happening in my current project. Thanks for the help.", "@paulocheque -- glad to hear it's working for you. One thing to also consider is the possibility you had nested `transaction()` blocks...Because the semantics of nested transactions may be confusing, I'd recommend using `atomic()` instead. By using `atomic()`, peewee will automatically use a transaction or savepoint where appropriate.", "I understand now my mistake. I was using two different `PostgresqlExtDatabase` intances. One for the User model declaration and another one for the queries. Now I am using a single `db` variable and it is working. Thanks for the help again." ]
2017-03-06T06:56:30
2017-03-06T20:21:59
2017-03-06T15:33:24
NONE
null
- Python 3.6 - peewee==2.8.7 Hi there, In the example below, two records (indexes 0 and 1) will be saved successfully in the database, although I am calling rollback. ``` db.connect() with db.transaction() as txn: for index, row in enumerate(rows): try: model = MyModel() if index == 2: raise Exception('This should cancel the entire transaction, right?') model.save() except Exception as e: print('Rollbacking') # yes, lets rollback txn.rollback() raise # With this, no commit will be made print('Commiting') # not being here txn.commit() db.close() ``` Is that correct?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1208/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1208/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1207
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1207/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1207/comments
https://api.github.com/repos/coleifer/peewee/issues/1207/events
https://github.com/coleifer/peewee/issues/1207
212,018,550
MDU6SXNzdWUyMTIwMTg1NTA=
1,207
select without commit?
{ "login": "knightliao", "id": 3657476, "node_id": "MDQ6VXNlcjM2NTc0NzY=", "avatar_url": "https://avatars.githubusercontent.com/u/3657476?v=4", "gravatar_id": "", "url": "https://api.github.com/users/knightliao", "html_url": "https://github.com/knightliao", "followers_url": "https://api.github.com/users/knightliao/followers", "following_url": "https://api.github.com/users/knightliao/following{/other_user}", "gists_url": "https://api.github.com/users/knightliao/gists{/gist_id}", "starred_url": "https://api.github.com/users/knightliao/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/knightliao/subscriptions", "organizations_url": "https://api.github.com/users/knightliao/orgs", "repos_url": "https://api.github.com/users/knightliao/repos", "events_url": "https://api.github.com/users/knightliao/events{/privacy}", "received_events_url": "https://api.github.com/users/knightliao/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee runs in autocommit mode unless you're within the scope of a transaction block, so any COMMIT issued as part of a SELECT query is occurring because a transaction is *not* active. If you're managing transactions outside of Peewee, then you may want to turn autocommit off (by passing `autocommit=False` in to the database constructor). I'd recommend against doing that, however.\r\n\r\nAssuming you're running transactions using either the `atomic()` or `transaction()` helpers, then there's nothing to worry about.", "thanks a lot :)" ]
2017-03-06T03:57:20
2017-03-07T06:09:21
2017-03-06T15:29:10
NONE
null
i found that every select sql will do commit at last in peewee. this may cause transaction. mybatis is a famous lib, it doesn't do transaction when it finds that select sql. will peewee implement " select without commit?" function?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1207/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1207/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1206
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1206/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1206/comments
https://api.github.com/repos/coleifer/peewee/issues/1206/events
https://github.com/coleifer/peewee/pull/1206
211,996,958
MDExOlB1bGxSZXF1ZXN0MTA5MTcyNzgy
1,206
Add interval field support for Postgres
{ "login": "alexlatchford", "id": 628146, "node_id": "MDQ6VXNlcjYyODE0Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/628146?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexlatchford", "html_url": "https://github.com/alexlatchford", "followers_url": "https://api.github.com/users/alexlatchford/followers", "following_url": "https://api.github.com/users/alexlatchford/following{/other_user}", "gists_url": "https://api.github.com/users/alexlatchford/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexlatchford/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexlatchford/subscriptions", "organizations_url": "https://api.github.com/users/alexlatchford/orgs", "repos_url": "https://api.github.com/users/alexlatchford/repos", "events_url": "https://api.github.com/users/alexlatchford/events{/privacy}", "received_events_url": "https://api.github.com/users/alexlatchford/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What Python data-type is used by psycopg2 to represent an interval in Postgres? I'd assume a `datetime.timedelta`? I'm good with merging the changes (though please rebase into a single commit and remove the PEP8 changes).", "Yep uses `timedelta` internally. Should be all handled transparently by `psycopg2` and the operations by the operators on `Node` from my initial tests.\r\n\r\nRebased as suggested and removed formatting.", "Looks like the test model differs from the model used in the test-case itself, which is causing the builds to fail. You mind fixing that, and maybe adding an integration test that actually creates the table and verifies the data and data-types being stored/retrieved from the DB?", "It was so close! Just needed to fix the tests up a bit. Any reason you closed this?", "Unfortunately the project I needed this for was cancelled and I'm unlikely to get around to fixing this up anytime soon so didn't want to clutter things up. Feel free to take it on if you think it's a good addition :)", "Thanks @alexlatchford -- I may do that when I've got a little free time. I appreciate the effort!", "Committed f4ebd78b990efc6f0fc57b9a4d81f0cd6ecdf276" ]
2017-03-06T00:06:03
2017-03-23T18:21:05
2017-03-21T04:51:28
CONTRIBUTOR
null
I can add/amend the tests if you think this is a good approach. PS. Sorry looks like my AutoPEP8 got in the way of the changes, I can remove if needs be.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1206/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1206/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1206", "html_url": "https://github.com/coleifer/peewee/pull/1206", "diff_url": "https://github.com/coleifer/peewee/pull/1206.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1206.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1205
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1205/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1205/comments
https://api.github.com/repos/coleifer/peewee/issues/1205/events
https://github.com/coleifer/peewee/pull/1205
211,981,188
MDExOlB1bGxSZXF1ZXN0MTA5MTYzODg5
1,205
Make 'create_or_get' correctly support composite unique indexes and keys
{ "login": "Necoro", "id": 68708, "node_id": "MDQ6VXNlcjY4NzA4", "avatar_url": "https://avatars.githubusercontent.com/u/68708?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Necoro", "html_url": "https://github.com/Necoro", "followers_url": "https://api.github.com/users/Necoro/followers", "following_url": "https://api.github.com/users/Necoro/following{/other_user}", "gists_url": "https://api.github.com/users/Necoro/gists{/gist_id}", "starred_url": "https://api.github.com/users/Necoro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Necoro/subscriptions", "organizations_url": "https://api.github.com/users/Necoro/orgs", "repos_url": "https://api.github.com/users/Necoro/repos", "events_url": "https://api.github.com/users/Necoro/events{/privacy}", "received_events_url": "https://api.github.com/users/Necoro/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Hmm... I received another pull-request with similar changes a while back and passed on it due to the complexity it introduced. My current thinking is that it'd be better to just remove `create_or_get` since it seems to cause confusion and the code one would need to write to work around it is very concise:\r\n\r\n```python\r\ntry:\r\n return MyObj.create(whatever='foo')\r\nexcept IntegrityError:\r\n return MyObj.get(MyObj.whatever == 'foo')\r\n```\r\n\r\nTo me the result does not justify the means (and the subtlety involved). So I think in the next minor release I'll just remove the method instead." ]
2017-03-05T20:32:09
2017-03-06T15:12:32
2017-03-06T15:12:32
CONTRIBUTOR
null
This fixes #1204
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1205/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1205/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1205", "html_url": "https://github.com/coleifer/peewee/pull/1205", "diff_url": "https://github.com/coleifer/peewee/pull/1205.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1205.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1204
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1204/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1204/comments
https://api.github.com/repos/coleifer/peewee/issues/1204/events
https://github.com/coleifer/peewee/issues/1204
211,975,660
MDU6SXNzdWUyMTE5NzU2NjA=
1,204
create_or_get returns wrong instance
{ "login": "Necoro", "id": 68708, "node_id": "MDQ6VXNlcjY4NzA4", "avatar_url": "https://avatars.githubusercontent.com/u/68708?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Necoro", "html_url": "https://github.com/Necoro", "followers_url": "https://api.github.com/users/Necoro/followers", "following_url": "https://api.github.com/users/Necoro/following{/other_user}", "gists_url": "https://api.github.com/users/Necoro/gists{/gist_id}", "starred_url": "https://api.github.com/users/Necoro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Necoro/subscriptions", "organizations_url": "https://api.github.com/users/Necoro/orgs", "repos_url": "https://api.github.com/users/Necoro/repos", "events_url": "https://api.github.com/users/Necoro/events{/privacy}", "received_events_url": "https://api.github.com/users/Necoro/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Is the create not raising an IntegrityError in the create_or_get case?", "The problem was a combined unique index. My PR should fix it.", "Thanks for your work on the PR. As I said in my comment on the PR, the code one needs to write to do a create-or-get is only a few lines long and, in my opinion, does not justify the complexity of the corresponding helper method. In the next minor release, I'll be removing `create_or_get()` since it seems to cause more confusion that actually help.", "That is a very good idea. I wasn't sure if I could suggest this.\r\n\r\nIn both the old and my improved state, there exist configurations (e.g. multiple unique indexes) where the wrong entry would be returned. Heck, it might not even be possible to say what the right entry would be: If you tried to insert an entry violating _two_ unique indexes at the same time, the method could return the entry for either of those.", "Exactly. For only the most trivial use-cases would that method be very helpful, and the resulting code to achieve the equivalent functionality is only a couple extra lines... Thanks for your work on this PR, I hope you don't feel it was time wasted." ]
2017-03-05T19:23:55
2017-03-06T19:37:23
2017-03-06T15:13:45
CONTRIBUTOR
null
```python >>> Tag.get(name='etf', prefix='wp') <Tag (#16) wp:etf> >>> Tag.create_or_get(name='etf', prefix='wp') (<Tag (#1) mime:*>, False) >>> Tag.get_or_create(name='etf', prefix='wp') (<Tag (#16) wp:etf>, False) ``` See above, should be self explanatory. Going to analyze (and hopefully fix) it now.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1204/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1204/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1203
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1203/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1203/comments
https://api.github.com/repos/coleifer/peewee/issues/1203/events
https://github.com/coleifer/peewee/pull/1203
211,905,556
MDExOlB1bGxSZXF1ZXN0MTA5MTIyMDU5
1,203
SQLite Closure Tables: Allow for many-to-many relations
{ "login": "Necoro", "id": 68708, "node_id": "MDQ6VXNlcjY4NzA4", "avatar_url": "https://avatars.githubusercontent.com/u/68708?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Necoro", "html_url": "https://github.com/Necoro", "followers_url": "https://api.github.com/users/Necoro/followers", "following_url": "https://api.github.com/users/Necoro/following{/other_user}", "gists_url": "https://api.github.com/users/Necoro/gists{/gist_id}", "starred_url": "https://api.github.com/users/Necoro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Necoro/subscriptions", "organizations_url": "https://api.github.com/users/Necoro/orgs", "repos_url": "https://api.github.com/users/Necoro/repos", "events_url": "https://api.github.com/users/Necoro/events{/privacy}", "received_events_url": "https://api.github.com/users/Necoro/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Cool, I may make some small tweaks here and there, but looks great, thank you!", "Actually, I've gone ahead and reverted this. It didn't seem to work when I started writing tests for it -- possibly I'm misunderstanding something?", "Could you give me an example of what was not working as expected?", "Ach, I take it back! I think I must've introduced a bug when I was editing the code to clean up some of the names.", "Changes merged, I swapped the `id_column` parameter for one named `referencing_key` instead and made them `VirtualIntegerFields`. Other than that, changes are intact.", "https://github.com/coleifer/peewee/blob/master/playhouse/sqlite_ext.py#L670-L758", "Thanks. The fields `idcolumn` and `parentcolumn` are still strings, though. See the docs from closure.c:\r\n```sql\r\nSELECT element.* FROM element, ct1\r\nWHERE element.groupid=ct1.id\r\nAND ct1.root=?1\r\nAND ct1.idcolumn='parentId'\r\nAND ct1.parentcolumn='groupId';\r\n```", "Oh shit. Thanks! Will re-fix your fix.", "04a3e022144ebf3db6a078ecd83f51dbbf766034" ]
2017-03-04T20:39:55
2017-03-05T20:06:18
2017-03-05T03:01:11
CONTRIBUTOR
null
Currently, the ClosureTable only allows for self-joins using the same table. But if you have many-to-many relations between one table using an intermediate table that was not expressible. With this PR, a self-many-to-many-relation is now supported (as rare as it might be -- I needed it ;)). I also took the liberty to update the documentation, but this probably could use a second look.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1203/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1203/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1203", "html_url": "https://github.com/coleifer/peewee/pull/1203", "diff_url": "https://github.com/coleifer/peewee/pull/1203.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1203.patch", "merged_at": "2017-03-05T03:01:11" }
https://api.github.com/repos/coleifer/peewee/issues/1202
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1202/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1202/comments
https://api.github.com/repos/coleifer/peewee/issues/1202/events
https://github.com/coleifer/peewee/pull/1202
211,902,713
MDExOlB1bGxSZXF1ZXN0MTA5MTIwNDM4
1,202
Make Model.get(val = None) work the same as Model.select().where(Model.val == None)
{ "login": "Necoro", "id": 68708, "node_id": "MDQ6VXNlcjY4NzA4", "avatar_url": "https://avatars.githubusercontent.com/u/68708?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Necoro", "html_url": "https://github.com/Necoro", "followers_url": "https://api.github.com/users/Necoro/followers", "following_url": "https://api.github.com/users/Necoro/following{/other_user}", "gists_url": "https://api.github.com/users/Necoro/gists{/gist_id}", "starred_url": "https://api.github.com/users/Necoro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Necoro/subscriptions", "organizations_url": "https://api.github.com/users/Necoro/orgs", "repos_url": "https://api.github.com/users/Necoro/repos", "events_url": "https://api.github.com/users/Necoro/events{/privacy}", "received_events_url": "https://api.github.com/users/Necoro/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nice, thanks!" ]
2017-03-04T19:51:37
2017-03-05T02:58:54
2017-03-05T02:58:51
CONTRIBUTOR
null
Currently `Model.select().where(val == None)` compiles into a `WHERE val IS NULL` clause. On the other hand `Model.get(val = None)` compiled into `WHERE val = NULL` and, if val is an FK field, tried to join. With this PR, this is fixed and Model.get behaves just like Model.select().where()
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1202/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1202/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1202", "html_url": "https://github.com/coleifer/peewee/pull/1202", "diff_url": "https://github.com/coleifer/peewee/pull/1202.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1202.patch", "merged_at": "2017-03-05T02:58:51" }
https://api.github.com/repos/coleifer/peewee/issues/1201
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1201/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1201/comments
https://api.github.com/repos/coleifer/peewee/issues/1201/events
https://github.com/coleifer/peewee/issues/1201
210,640,050
MDU6SXNzdWUyMTA2NDAwNTA=
1,201
After updating to 2.8.8 from 2.8.5, started seeing a bug that occurs on 2.8.7 as well
{ "login": "savraj", "id": 387613, "node_id": "MDQ6VXNlcjM4NzYxMw==", "avatar_url": "https://avatars.githubusercontent.com/u/387613?v=4", "gravatar_id": "", "url": "https://api.github.com/users/savraj", "html_url": "https://github.com/savraj", "followers_url": "https://api.github.com/users/savraj/followers", "following_url": "https://api.github.com/users/savraj/following{/other_user}", "gists_url": "https://api.github.com/users/savraj/gists{/gist_id}", "starred_url": "https://api.github.com/users/savraj/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/savraj/subscriptions", "organizations_url": "https://api.github.com/users/savraj/orgs", "repos_url": "https://api.github.com/users/savraj/repos", "events_url": "https://api.github.com/users/savraj/events{/privacy}", "received_events_url": "https://api.github.com/users/savraj/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I bumped into this too. The commit that causes this is 9e76c999868197a4911fa2fa457c50ab42431ff1, which came about because of #1108.\r\n\r\nThe pull request explains why the commit is necessary and how you can solve your problem, but in short use `our_db.get_conn()` instead of `our_db.connect()`.\r\n\r\nIf this is a permanent solution then the docs should probably be updated (especially the [Adding Request Hooks](http://docs.peewee-orm.com/en/latest/peewee/database.html#adding-request-hooks) section), but I'll leave that up to @coleifer to decide.", "Thanks for the quick reply Matt, much appreciated!", "Also you can use [`FlaskDB`](https://github.com/coleifer/peewee/blob/master/playhouse/flask_utils.py#L78) from `playhouse.flask_utils` module", "Related: Where are the release notes for 2.8.5 through 2.8.8? :)", "> In our boilerplate Flask connection open/close code (copied from the docs), and it happens only on the first time our server comes up running on the google app engine development server.\r\n\r\nAre you doing anything with the database at module-scope? For instance, creating tables, or anything that might unintentionally cause a connection to be opened?", "@flother -- thanks, by the way, for providing the details on the commit and a workaround.\r\n\r\nThe change prevents connections from being opened and then subsequently not closed because the reference to them was overwritten with a 2nd connection.\r\n\r\nThe OperationalError is clue-ing you in to a spot in your code where you've already got an open connection for the given thread and are trying to open a new one on top of it. Like I said -- check for database accesses at module scope or during application startup, those are likely to be the culprits.\r\n\r\nAs for using `get_conn()` in the hooks, I still think it is advisable to use `connect()`, because in most applications an exception would only be raised because the developer had forgotten to close one somewhere...which seems like a bug." ]
2017-02-27T23:28:06
2017-03-01T16:03:20
2017-03-01T16:03:20
NONE
null
Hi Charles and team, First, many thanks for creating an AMAZING ORM -- we depend on it and we love its simplicity. So the weird bug is, we see a `OperationalError('Connection already open')` In our boilerplate Flask connection open/close code (copied from the docs), and it happens only on the first time our server comes up running on the google app engine development server. ``` # set up DB handling @app.before_request def connect_db(): our_db.connect() # this raises an operational error only on the first request @app.teardown_request def close_db(exc): if not our_db.is_closed(): our_db.close() ``` Thing is, I can move back to 2.8.5 and everything works normally -- no OperationalError is raised. Though we looked at the commits between .5 and .8 and didn't see anything unusual. Your insight is appreciated! Thank you in advance, and again, we love Peewee!!! (Our temporary fix is sticking with 2.8.5) -savraj
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1201/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1201/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1200
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1200/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1200/comments
https://api.github.com/repos/coleifer/peewee/issues/1200/events
https://github.com/coleifer/peewee/issues/1200
210,344,216
MDU6SXNzdWUyMTAzNDQyMTY=
1,200
ForeignKey: Do not load object if only the pk is accessed
{ "login": "Necoro", "id": 68708, "node_id": "MDQ6VXNlcjY4NzA4", "avatar_url": "https://avatars.githubusercontent.com/u/68708?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Necoro", "html_url": "https://github.com/Necoro", "followers_url": "https://api.github.com/users/Necoro/followers", "following_url": "https://api.github.com/users/Necoro/following{/other_user}", "gists_url": "https://api.github.com/users/Necoro/gists{/gist_id}", "starred_url": "https://api.github.com/users/Necoro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Necoro/subscriptions", "organizations_url": "https://api.github.com/users/Necoro/orgs", "repos_url": "https://api.github.com/users/Necoro/repos", "events_url": "https://api.github.com/users/Necoro/events{/privacy}", "received_events_url": "https://api.github.com/users/Necoro/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I think that we shouldn't break the convention that accessing the foreign key will, if necessary, load the related object. It makes the code simpler, too.\r\n\r\nJust compare the IDs if that's all you need:\r\n\r\n```python\r\nif tweet.user_id:\r\n```\r\n\r\nOr\r\n\r\n```python\r\nif tweet.user_id == someUser.id:\r\n```" ]
2017-02-26T20:11:51
2017-02-26T23:29:15
2017-02-26T23:29:15
CONTRIBUTOR
null
Given two models `Tweet` and `User` with the well-known relations: When accessing `tweet.user` Peewee currently always fetches the complete user. Even in cases like ```python if tweet.user: # we have a user, do something else: # no user, eh? ``` and ```python if tweet.user == someUser: # do something ``` In my opinion, in both cases the loading is not needed because it is sufficient to check whether `tweet.user_id is not None` and `tweet.user_id == someUser.id`, respectively. (And btw, that you can access the ids directly that way is not documented, is it? I had to inspect peewee's code to find it). I think, that implementing this behavior should be fairly straight-forward. If you are not opposed, I'd give it a try. (Of course, this only works with enabled foreign keys, so might be a trap for incautious sqlite users.)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1200/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1200/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1199
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1199/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1199/comments
https://api.github.com/repos/coleifer/peewee/issues/1199/events
https://github.com/coleifer/peewee/issues/1199
210,246,890
MDU6SXNzdWUyMTAyNDY4OTA=
1,199
db.atomic() does not set transaction_type
{ "login": "jberkel", "id": 18891, "node_id": "MDQ6VXNlcjE4ODkx", "avatar_url": "https://avatars.githubusercontent.com/u/18891?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jberkel", "html_url": "https://github.com/jberkel", "followers_url": "https://api.github.com/users/jberkel/followers", "following_url": "https://api.github.com/users/jberkel/following{/other_user}", "gists_url": "https://api.github.com/users/jberkel/gists{/gist_id}", "starred_url": "https://api.github.com/users/jberkel/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jberkel/subscriptions", "organizations_url": "https://api.github.com/users/jberkel/orgs", "repos_url": "https://api.github.com/users/jberkel/repos", "events_url": "https://api.github.com/users/jberkel/events{/privacy}", "received_events_url": "https://api.github.com/users/jberkel/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thanks for the report, pushed 2.8.8." ]
2017-02-25T17:01:42
2017-02-26T23:27:40
2017-02-26T23:27:39
CONTRIBUTOR
null
Regression after updating from 2.8.5 to 2.8.7: ``` File "/Users/jan/projects/lexi/importer/src/main/python/lexi/models/fts.py", line 160, in index with database.atomic(): File "/Users/jan/projects/lexi/importer/venv-python2/lib/python2.7/site-packages/peewee.py", line 4356, in __enter__ return self.context_manager.__enter__() File "/Users/jan/projects/lexi/importer/venv-python2/lib/python2.7/site-packages/peewee.py", line 4381, in __enter__ if self.db.transaction_depth() == 0: self._begin() File "/Users/jan/projects/lexi/importer/venv-python2/lib/python2.7/site-packages/playhouse/apsw_ext.py", line 46, in _begin self.db.begin(self.lock_type) File "/Users/jan/projects/lexi/importer/venv-python2/lib/python2.7/site-packages/playhouse/apsw_ext.py", line 127, in begin self.get_cursor().execute('begin %s;' % lock_type) File "src/cursor.c", line 1019, in APSWCursor_execute.sqlite3_prepare File "src/statementcache.c", line 386, in sqlite3_prepare SQLError: SQLError: near "None": syntax error ``` class Database: ```python def atomic(self, transaction_type=None): return _atomic(self, transaction_type) ``` ```python class _atomic(_callable_context_manager): def __enter__(self): if self.db.transaction_depth() == 0: self.context_manager = self.db.transaction(self.transaction_type) ... ``` class APSWDatabase: ```python def begin(self, lock_type='deferred'): self.get_cursor().execute('begin %s;' % lock_type) ^^^^^^^^^ = None ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1199/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1199/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1198
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1198/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1198/comments
https://api.github.com/repos/coleifer/peewee/issues/1198/events
https://github.com/coleifer/peewee/issues/1198
209,974,012
MDU6SXNzdWUyMDk5NzQwMTI=
1,198
Is there a possibility of model.save() returning 0
{ "login": "Siva7891", "id": 4815214, "node_id": "MDQ6VXNlcjQ4MTUyMTQ=", "avatar_url": "https://avatars.githubusercontent.com/u/4815214?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Siva7891", "html_url": "https://github.com/Siva7891", "followers_url": "https://api.github.com/users/Siva7891/followers", "following_url": "https://api.github.com/users/Siva7891/following{/other_user}", "gists_url": "https://api.github.com/users/Siva7891/gists{/gist_id}", "starred_url": "https://api.github.com/users/Siva7891/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Siva7891/subscriptions", "organizations_url": "https://api.github.com/users/Siva7891/orgs", "repos_url": "https://api.github.com/users/Siva7891/repos", "events_url": "https://api.github.com/users/Siva7891/events{/privacy}", "received_events_url": "https://api.github.com/users/Siva7891/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Ummm...that's an interesting question, I guess... I think that you shouldn't need to even check the return value. An exception will be raised if a constraint is violated, for instance. So calls to `save()` should really be assumed to work unless an exception is raised.", "Thanks for replying much faster. " ]
2017-02-24T06:56:27
2017-02-24T17:29:03
2017-02-24T16:28:43
NONE
null
1) When we try to insert a new row (i.e., model class's object) using model.save() (or model.save(forceinsert=True), will it ever return 0.? If we had primary key conflict, then we receive an exception. So can we safely assume that model.save() will always insert that object and if any problem, it would raise an exception 1) When we try to update a row (i.e., model class's object) using model.save() will it ever return 0? Can we safely assume that model.save() will always update that object and if any problem, it would raise an exception? I started to use peewee very recently on a small sized project. Currently, I am writing a wrapper code for all the model.save and handling the situation if the response is not '1'? It is a right practice?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1198/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1198/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1197
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1197/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1197/comments
https://api.github.com/repos/coleifer/peewee/issues/1197/events
https://github.com/coleifer/peewee/issues/1197
209,147,924
MDU6SXNzdWUyMDkxNDc5MjQ=
1,197
MemoryError when querying database from Process
{ "login": "HaraldNordgren", "id": 9569897, "node_id": "MDQ6VXNlcjk1Njk4OTc=", "avatar_url": "https://avatars.githubusercontent.com/u/9569897?v=4", "gravatar_id": "", "url": "https://api.github.com/users/HaraldNordgren", "html_url": "https://github.com/HaraldNordgren", "followers_url": "https://api.github.com/users/HaraldNordgren/followers", "following_url": "https://api.github.com/users/HaraldNordgren/following{/other_user}", "gists_url": "https://api.github.com/users/HaraldNordgren/gists{/gist_id}", "starred_url": "https://api.github.com/users/HaraldNordgren/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/HaraldNordgren/subscriptions", "organizations_url": "https://api.github.com/users/HaraldNordgren/orgs", "repos_url": "https://api.github.com/users/HaraldNordgren/repos", "events_url": "https://api.github.com/users/HaraldNordgren/events{/privacy}", "received_events_url": "https://api.github.com/users/HaraldNordgren/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Possibly related to https://github.com/ghaering/pysqlite/issues/110", "If you're iterating over a large result set, peewee caches rows in-memory (to make subsequent iterations/indexing operations fast). In the case of a single-shot iteration over a lot of rows, though, this can OOM you.\r\n\r\nTo fix, just make this change to the problematic line of code:\r\n\r\n```python\r\nwhile True:\r\n # Note we add \".iterator()\"\r\n for row in FileModel.select().iterator():\r\n ...\r\n```\r\n\r\nPlease read:\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/querying.html#iterating-over-lots-of-rows", "This happens for an empty database too.", "then I highly doubt the issue is in Peewee." ]
2017-02-21T13:38:51
2017-02-22T14:09:56
2017-02-22T13:29:29
NONE
null
I am trying to create a program with 3 processes that read from the same database. The code was working before I started introducing processes. I am getting MemoryError when performing a `select()`. I suspect there is something wrong with sharing of resources: **models.py** ```python from playhouse.pool import PooledSqliteExtDatabase file_scanner_database = PooledSqliteExtDatabase( None, max_connections=32, ) class FileModel(Model): class Meta: database = file_scanner_database ``` **main.py** ```python from file_scanner import FileScanner from models import file_scanner_database from models import FileModel from multiprocessing import Process def create_scanner_agent(data): scanner = FileScanner(data) scanner.start_scanner() shared_info = {'db_location': '/absolute/path/to/database'} file_scanner_database.init(shared_info['db_location']) file_scanner_database.connect() file_scanner_database.create_tables([FileModel], safe=True) new_process = Process( target=create_scanner_agent, args=(shared_info,) ) new_process.daemon = True new_process.start() try: new_process.join() except KeyboardInterrupt: pass new_process.terminate() ``` **file_scanner.py** ```python from models import file_scanner_database from models import FileModel class FileScanner: def __init__(self, data): for k, v in data.items(): setattr(self, k, v) file_scanner_database.init(self.db_location) file_scanner_database.connect() def start_scanner(self): while True: # THIS IS WHERE THE PROGRAM CRASHES for row in FileModel.select(): ... ``` If I use `Thread` instead it seems to work.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1197/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1197/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1196
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1196/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1196/comments
https://api.github.com/repos/coleifer/peewee/issues/1196/events
https://github.com/coleifer/peewee/pull/1196
208,739,212
MDExOlB1bGxSZXF1ZXN0MTA2OTEyNTkx
1,196
Give TypeError if calling 'update', etc. from Model instance instead of from class
{ "login": "HaraldNordgren", "id": 9569897, "node_id": "MDQ6VXNlcjk1Njk4OTc=", "avatar_url": "https://avatars.githubusercontent.com/u/9569897?v=4", "gravatar_id": "", "url": "https://api.github.com/users/HaraldNordgren", "html_url": "https://github.com/HaraldNordgren", "followers_url": "https://api.github.com/users/HaraldNordgren/followers", "following_url": "https://api.github.com/users/HaraldNordgren/following{/other_user}", "gists_url": "https://api.github.com/users/HaraldNordgren/gists{/gist_id}", "starred_url": "https://api.github.com/users/HaraldNordgren/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/HaraldNordgren/subscriptions", "organizations_url": "https://api.github.com/users/HaraldNordgren/orgs", "repos_url": "https://api.github.com/users/HaraldNordgren/repos", "events_url": "https://api.github.com/users/HaraldNordgren/events{/privacy}", "received_events_url": "https://api.github.com/users/HaraldNordgren/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It seems that Travis still builds from HEAD of origin/master with the PR commit placed on top, so this also fails.", "Reverting \"Move cdefs back into extern from block\" and \"Bring back tests\" makes the tests work again.\r\n\r\nAgain, this branch probably should not be merged. But at least my commit is not breaking anything." ]
2017-02-19T19:18:30
2017-02-20T21:12:17
2017-02-20T16:24:49
NONE
null
Same as #1195 but based on the latest master commit with passing tests
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1196/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1196/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1196", "html_url": "https://github.com/coleifer/peewee/pull/1196", "diff_url": "https://github.com/coleifer/peewee/pull/1196.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1196.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1195
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1195/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1195/comments
https://api.github.com/repos/coleifer/peewee/issues/1195/events
https://github.com/coleifer/peewee/pull/1195
208,736,780
MDExOlB1bGxSZXF1ZXN0MTA2OTExMzU3
1,195
Give TypeError if calling 'update', etc. from Model instance instead of from class
{ "login": "HaraldNordgren", "id": 9569897, "node_id": "MDQ6VXNlcjk1Njk4OTc=", "avatar_url": "https://avatars.githubusercontent.com/u/9569897?v=4", "gravatar_id": "", "url": "https://api.github.com/users/HaraldNordgren", "html_url": "https://github.com/HaraldNordgren", "followers_url": "https://api.github.com/users/HaraldNordgren/followers", "following_url": "https://api.github.com/users/HaraldNordgren/following{/other_user}", "gists_url": "https://api.github.com/users/HaraldNordgren/gists{/gist_id}", "starred_url": "https://api.github.com/users/HaraldNordgren/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/HaraldNordgren/subscriptions", "organizations_url": "https://api.github.com/users/HaraldNordgren/orgs", "repos_url": "https://api.github.com/users/HaraldNordgren/repos", "events_url": "https://api.github.com/users/HaraldNordgren/events{/privacy}", "received_events_url": "https://api.github.com/users/HaraldNordgren/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Related to https://github.com/coleifer/peewee/issues/1192", "This grosses up the code quite a bit. They already have the classmethod decorator.", "I agree that it grosses up the code a bit. But it's very useful.\r\n\r\nOh well, it's your repo.\r\n ", "The grossness isn't a reflection of your coding ability, I should make that clear -- it's just one of those problems that requires a kinda gnarly fix. Thanks for the patch, I'm sorry if it was wasted time on your part." ]
2017-02-19T18:41:22
2018-09-18T13:54:15
2017-02-20T16:25:22
NONE
null
I hit a snag with this that took me hours to debug. Since these methods really only make sense as class methods, I don't think you should to be able to call them from an instance.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1195/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1195/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1195", "html_url": "https://github.com/coleifer/peewee/pull/1195", "diff_url": "https://github.com/coleifer/peewee/pull/1195.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1195.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1194
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1194/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1194/comments
https://api.github.com/repos/coleifer/peewee/issues/1194/events
https://github.com/coleifer/peewee/pull/1194
208,691,550
MDExOlB1bGxSZXF1ZXN0MTA2ODg3MTQ0
1,194
Fixed an issue where not having a primary key would cause create queries to crash
{ "login": "divmgl", "id": 5452298, "node_id": "MDQ6VXNlcjU0NTIyOTg=", "avatar_url": "https://avatars.githubusercontent.com/u/5452298?v=4", "gravatar_id": "", "url": "https://api.github.com/users/divmgl", "html_url": "https://github.com/divmgl", "followers_url": "https://api.github.com/users/divmgl/followers", "following_url": "https://api.github.com/users/divmgl/following{/other_user}", "gists_url": "https://api.github.com/users/divmgl/gists{/gist_id}", "starred_url": "https://api.github.com/users/divmgl/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/divmgl/subscriptions", "organizations_url": "https://api.github.com/users/divmgl/orgs", "repos_url": "https://api.github.com/users/divmgl/repos", "events_url": "https://api.github.com/users/divmgl/events{/privacy}", "received_events_url": "https://api.github.com/users/divmgl/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-02-19T03:37:42
2017-02-19T03:42:37
2017-02-19T03:42:37
NONE
null
Fixes #1193 cc @coleifer
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1194/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1194/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1194", "html_url": "https://github.com/coleifer/peewee/pull/1194", "diff_url": "https://github.com/coleifer/peewee/pull/1194.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1194.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1193
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1193/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1193/comments
https://api.github.com/repos/coleifer/peewee/issues/1193/events
https://github.com/coleifer/peewee/issues/1193
208,686,855
MDU6SXNzdWUyMDg2ODY4NTU=
1,193
Many to many creation results in AttributeError
{ "login": "divmgl", "id": 5452298, "node_id": "MDQ6VXNlcjU0NTIyOTg=", "avatar_url": "https://avatars.githubusercontent.com/u/5452298?v=4", "gravatar_id": "", "url": "https://api.github.com/users/divmgl", "html_url": "https://github.com/divmgl", "followers_url": "https://api.github.com/users/divmgl/followers", "following_url": "https://api.github.com/users/divmgl/following{/other_user}", "gists_url": "https://api.github.com/users/divmgl/gists{/gist_id}", "starred_url": "https://api.github.com/users/divmgl/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/divmgl/subscriptions", "organizations_url": "https://api.github.com/users/divmgl/orgs", "repos_url": "https://api.github.com/users/divmgl/repos", "events_url": "https://api.github.com/users/divmgl/events{/privacy}", "received_events_url": "https://api.github.com/users/divmgl/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is definitely not the ideal scenario, but it fixed my errors so I can continue development... \r\n\r\ncc @coleifer ", "Actually this breaks other functionality... so disregard. \r\n\r\nHad to do this instead:\r\n\r\n```python\r\ndb.execute_sql(\"\"\"\r\n INSERT INTO account_board (account_id, board_id)\r\n VALUES (%s, %s)\r\n\"\"\", (session[\"id\"], b.id))\r\n```", "You're calling Board.create().execute() which is weird...", "Sorry, I deleted my previous comment, because it's actually not technically necessary to use the \"_id\" accessor when passing in the plain old integer foreign key ID (instead of a related model instance).\r\n\r\nI'm having trouble with your example -- it doesn't make sense, is that from your actual code or is it something you made up for the ticket?\r\n\r\n`Board.create(**kwargs).execute()` doesn't make any sense.", "I see that part of the issue is related to having PRIMARY KEY=False. Why not make a composite key on both fields instead?\r\n\r\n```\r\nprimary_key = CompositeKey('account', 'board')\r\n```\r\n\r\nOr does that just cause more issues for you?", "Let me try making a composite key. I'm using Postgres and it doesn't\r\nsupport composite keys but it does support adding a unique index with two\r\nor more columns.\r\n\r\nI didn't mean to put `Board.create`, I meant to put `Board.insert`. Also\r\nthe code is copy/pasted. I'll try your suggestions and get back to you.\r\nThanks for your help.", "@coleifer i modified my code in my OP to reflect your changes. I'm now getting this error:\r\n\r\n```\r\npeewee.ProgrammingError: column \"id\" does not exist\r\nLINE 1: ...rd\" (\"account_id\", \"board_id\") VALUES (2, 79) RETURNING \"id\"\r\n```\r\n\r\n", "Disregard, I got it to work :) thanks @coleifer, I just needed to know about the `CompositeKey` class" ]
2017-02-19T01:43:23
2017-02-20T21:11:00
2017-02-20T19:10:17
NONE
null
Getting an attribute error when saving a model with two foreign key relationships. ```python class Account(BaseModel): created_on = DateTimeField(null=False) username = CharField(null=False, unique=True) password = CharField(null=False) salt = CharField(null=False) name = CharField(null=False) last_session_on = DateTimeField() class Board(BaseModel): name = CharField() created_on = DateTimeField(null=False) slug = CharField(null=False) class AccountBoard(BaseModel): account = ForeignKeyField(Account, null=False, unique=True) board = ForeignKeyField(Board, null=False, unique=True) primary_key = CompositeKey('account', 'board') class Meta: db_table = "account_board" kwargs = {"name": model.get("name")} # App crashes here. board.id and session["id"] are returning integers with db.atomic(): board = Board.create(**kwargs) AccountBoard.create(board=board, account=session["id"]) ``` ``` builtins.AttributeError AttributeError: 'bool' object has no attribute 'as_entity' ``` Can anyone point me in the right direction? I really don't understand what's wrong about this code.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1193/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1193/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1192
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1192/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1192/comments
https://api.github.com/repos/coleifer/peewee/issues/1192/events
https://github.com/coleifer/peewee/issues/1192
207,238,316
MDU6SXNzdWUyMDcyMzgzMTY=
1,192
Update() on row affects every row and should be disallowed
{ "login": "HaraldNordgren", "id": 9569897, "node_id": "MDQ6VXNlcjk1Njk4OTc=", "avatar_url": "https://avatars.githubusercontent.com/u/9569897?v=4", "gravatar_id": "", "url": "https://api.github.com/users/HaraldNordgren", "html_url": "https://github.com/HaraldNordgren", "followers_url": "https://api.github.com/users/HaraldNordgren/followers", "following_url": "https://api.github.com/users/HaraldNordgren/following{/other_user}", "gists_url": "https://api.github.com/users/HaraldNordgren/gists{/gist_id}", "starred_url": "https://api.github.com/users/HaraldNordgren/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/HaraldNordgren/subscriptions", "organizations_url": "https://api.github.com/users/HaraldNordgren/orgs", "repos_url": "https://api.github.com/users/HaraldNordgren/repos", "events_url": "https://api.github.com/users/HaraldNordgren/events{/privacy}", "received_events_url": "https://api.github.com/users/HaraldNordgren/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "And the correct syntax in this case seems to be\r\n\r\n for row in rows:\r\n <do things>\r\n row.job_status = NEW_STATUS\r\n row.save()", "`update` is a classmethod, and is document as such. An update without a where clause is going to cause problems, obviously, as you found." ]
2017-02-13T14:47:34
2017-02-13T15:21:07
2017-02-13T15:21:07
NONE
null
I used this code to update rows, and it seems that the update() function used in this way updates more than the current row. Possible every row in the model. Maybe it should be altogether disallowed to avoid mistakes? ``` rows = Model.select().where( Model.status == SOME_STATUS ) for row in rows: <do things, then depending on results do> row.update( job_status=SOME_NEW_STATUS ).execute() ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1192/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1192/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1191
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1191/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1191/comments
https://api.github.com/repos/coleifer/peewee/issues/1191/events
https://github.com/coleifer/peewee/issues/1191
207,176,021
MDU6SXNzdWUyMDcxNzYwMjE=
1,191
TypeError: sequence item 0: expected str instance, BaseModel found
{ "login": "raphael0202", "id": 9609923, "node_id": "MDQ6VXNlcjk2MDk5MjM=", "avatar_url": "https://avatars.githubusercontent.com/u/9609923?v=4", "gravatar_id": "", "url": "https://api.github.com/users/raphael0202", "html_url": "https://github.com/raphael0202", "followers_url": "https://api.github.com/users/raphael0202/followers", "following_url": "https://api.github.com/users/raphael0202/following{/other_user}", "gists_url": "https://api.github.com/users/raphael0202/gists{/gist_id}", "starred_url": "https://api.github.com/users/raphael0202/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/raphael0202/subscriptions", "organizations_url": "https://api.github.com/users/raphael0202/orgs", "repos_url": "https://api.github.com/users/raphael0202/repos", "events_url": "https://api.github.com/users/raphael0202/events{/privacy}", "received_events_url": "https://api.github.com/users/raphael0202/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "`.join(User, Bot)` is not valid. The docs are pretty clear on the method: http://docs.peewee-orm.com/en/latest/peewee/api.html#Query.join\r\n\r\nInterestingly, since you're joining the same model twice, you'll need to work around Peewee's concept of the query context. Here's what you're probably going for:\r\n\r\n```python\r\n return (Message.select(User, Message, Bot)\r\n .join(User)\r\n .switch(Message) # Query context was User, since we want to join message->bot, we switch back.\r\n .join(Bot)\r\n .where(User.id == user_id,\r\n Bot.id == bot_id,\r\n Message.pub_datetime.between(\r\n start_datetime,\r\n end_datetime)))\r\n```", "Oh my bad, I missed this point in the doc. Thank you for the code fix.\r\nI think however that it would be great if the error message were more user-friendly." ]
2017-02-13T10:27:21
2017-02-14T07:49:50
2017-02-13T16:58:21
NONE
null
This error can be reproduced with the following script: ``` import peewee import datetime db = peewee.SqliteDatabase(database='test.db') class BaseModel(peewee.Model): class Meta: database = db class User(BaseModel): username = peewee.CharField(max_length=200, null=True) class Bot(BaseModel): name = peewee.CharField(max_length=30, unique=True, index=True) class Message(BaseModel): user = peewee.ForeignKeyField(User, related_name='messages', null=True) bot = peewee.ForeignKeyField(Bot, related_name='messages', null=True) pub_datetime = peewee.DateTimeField() @classmethod def date_filter(cls, bot_id, user_id, target_datetime=datetime.datetime.now()): start_datetime = target_datetime.replace(hour=0, minute=0) end_datetime = start_datetime.replace(day=start_datetime.day + 1) return (Message.select(User, Message, Bot) .join(User, Bot) .where(User.id == user_id, Bot.id == bot_id, Message.pub_datetime.between( start_datetime, end_datetime))) if __name__ == '__main__': db.create_tables([Bot, Message, User]) bot = Bot.create(name='test') user = User.create(username='username') Message.create(bot=bot, user=user, pub_datetime=datetime.datetime.now()) messages = Message.date_filter(bot.id, user.id) print(messages) ``` with the following traceback: ``` Traceback (most recent call last): File "/home/raphael/git_core/likeabot/test_db.py", line 47, in <module> print(messages) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 2690, in __repr__ sql, params = self.sql() File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 3117, in sql return self.compiler().generate_select(self) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1951, in generate_select return self.build_query(clauses, alias_map) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1835, in build_query return self.parse_node(Clause(*clauses), alias_map) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1788, in parse_node sql, params, unknown = self._parse(node, alias_map, conv) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1754, in _parse sql, params = self._parse_map[node_type](node, alias_map, conv) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1682, in _parse_clause node.nodes, alias_map, conv, node.glue) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1813, in parse_node_list node_sql, node_params = self.parse_node(node, alias_map, conv) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1788, in parse_node sql, params, unknown = self._parse(node, alias_map, conv) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1754, in _parse sql, params = self._parse_map[node_type](node, alias_map, conv) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1682, in _parse_clause node.nodes, alias_map, conv, node.glue) File "/home/raphael/.virtualenvs/likeabot/lib/python3.5/site-packages/peewee.py", line 1816, in parse_node_list return glue.join(sql), params TypeError: sequence item 0: expected str instance, BaseModel found ``` The error is gone when deleting the Message.user foreign key, and the User references in where and join clauses. Environment: - Python 3.5 - Peewee 2.8.5
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1191/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1191/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1190
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1190/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1190/comments
https://api.github.com/repos/coleifer/peewee/issues/1190/events
https://github.com/coleifer/peewee/pull/1190
206,918,971
MDExOlB1bGxSZXF1ZXN0MTA1NzE0OTM4
1,190
SqliteQueueDatabase exception fix for #1189
{ "login": "krikunts", "id": 2005786, "node_id": "MDQ6VXNlcjIwMDU3ODY=", "avatar_url": "https://avatars.githubusercontent.com/u/2005786?v=4", "gravatar_id": "", "url": "https://api.github.com/users/krikunts", "html_url": "https://github.com/krikunts", "followers_url": "https://api.github.com/users/krikunts/followers", "following_url": "https://api.github.com/users/krikunts/following{/other_user}", "gists_url": "https://api.github.com/users/krikunts/gists{/gist_id}", "starred_url": "https://api.github.com/users/krikunts/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/krikunts/subscriptions", "organizations_url": "https://api.github.com/users/krikunts/orgs", "repos_url": "https://api.github.com/users/krikunts/repos", "events_url": "https://api.github.com/users/krikunts/events{/privacy}", "received_events_url": "https://api.github.com/users/krikunts/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "No, `exc` is set in the `else` clause, which runs if no Exception is raised...", "I was mistaken! In Python 3, the expression: `except <Exception> as <var>` does not keep `<var>` in scope beyond the exception block. So you were correct in raising this issue. It is fixed in `master` now.", "Great! My bad, I didn't specify python version (it was 3.5, for the record)" ]
2017-02-10T22:08:08
2017-02-14T08:43:15
2017-02-14T01:51:38
NONE
null
Fixing reference before assignment error #1189
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1190/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1190/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1190", "html_url": "https://github.com/coleifer/peewee/pull/1190", "diff_url": "https://github.com/coleifer/peewee/pull/1190.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1190.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1189
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1189/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1189/comments
https://api.github.com/repos/coleifer/peewee/issues/1189/events
https://github.com/coleifer/peewee/issues/1189
206,916,585
MDU6SXNzdWUyMDY5MTY1ODU=
1,189
SqliteQueueDatabase Writer.execute() error
{ "login": "krikunts", "id": 2005786, "node_id": "MDQ6VXNlcjIwMDU3ODY=", "avatar_url": "https://avatars.githubusercontent.com/u/2005786?v=4", "gravatar_id": "", "url": "https://api.github.com/users/krikunts", "html_url": "https://github.com/krikunts", "followers_url": "https://api.github.com/users/krikunts/followers", "following_url": "https://api.github.com/users/krikunts/following{/other_user}", "gists_url": "https://api.github.com/users/krikunts/gists{/gist_id}", "starred_url": "https://api.github.com/users/krikunts/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/krikunts/subscriptions", "organizations_url": "https://api.github.com/users/krikunts/orgs", "repos_url": "https://api.github.com/users/krikunts/repos", "events_url": "https://api.github.com/users/krikunts/events{/privacy}", "received_events_url": "https://api.github.com/users/krikunts/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What exception is underneath the `UnboundLocalError` I wonder? I would've thought that catching Exception would suffice but it looks like whatever error is being raised extends `BaseException` instead?", "I couldn't replicate. I added a test-case in which invalid SQL is executed via the AsyncCursor and it all works as I'd expect. I've pushed a new release (2.8.6) in case the bug existed in the last release, however." ]
2017-02-10T21:55:45
2017-02-14T01:59:30
2017-02-14T01:59:30
NONE
null
Hello! I read your blogpost about SqliteQueueDatabase and want to try it out, but I have an error using SqliteQueueDatabase UnboundLocalError: local variable 'exc' referenced before assignment https://github.com/coleifer/peewee/blob/d99f4a2649ce02da2f67769e381e51264f3c3eac/playhouse/sqliteq.py#L176 If there is exception during sql execution, the exc var is not visible outside of except block
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1189/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1189/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1188
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1188/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1188/comments
https://api.github.com/repos/coleifer/peewee/issues/1188/events
https://github.com/coleifer/peewee/issues/1188
206,572,129
MDU6SXNzdWUyMDY1NzIxMjk=
1,188
database locked even with minimal concurrency
{ "login": "rayzorben", "id": 7737834, "node_id": "MDQ6VXNlcjc3Mzc4MzQ=", "avatar_url": "https://avatars.githubusercontent.com/u/7737834?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rayzorben", "html_url": "https://github.com/rayzorben", "followers_url": "https://api.github.com/users/rayzorben/followers", "following_url": "https://api.github.com/users/rayzorben/following{/other_user}", "gists_url": "https://api.github.com/users/rayzorben/gists{/gist_id}", "starred_url": "https://api.github.com/users/rayzorben/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rayzorben/subscriptions", "organizations_url": "https://api.github.com/users/rayzorben/orgs", "repos_url": "https://api.github.com/users/rayzorben/repos", "events_url": "https://api.github.com/users/rayzorben/events{/privacy}", "received_events_url": "https://api.github.com/users/rayzorben/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I wrote a blog post on this subject, http://charlesleifer.com/blog/multi-threaded-sqlite-without-the-operationalerrors/\r\n\r\nBut, tl;dr is that you probably are running up against timeouts while waiting for the write lock...possibly?\r\n\r\nYou can try increasing the timeout, by passing `timeout=10` or more to the initialization method of `SqliteDatabase`. Or you can try out `SqliteQueueDatabase` which works as a drop-in replacement for `SqliteDatabase`. Note that you cannot use transactions if you're using `SqliteQueueDatabase`, however.\r\n\r\nI'd suggest taking a look at the post. I'd also suggest that, if you're planning to use SQLite in a multi-threaded application, you read the docs on how locking works. The SQLite docs are really good.", "@coleifer Thanks for that, will look at it. In order to diagnose I ran it single threaded, and I can see the problem really clearly. Most writes happen in .02-.04 seconds. However every once in a while I will get writes that take 1-7 seconds, even up to 49 seconds!\r\n\r\nObviously even a timeout of 10 won't work, so hopefully the post will help out, but is there any way to diagnose why these writes are taking so long comparatively?", "Posting here because it is the last issue related to the database locked error. I've been dealing with this issue the last few months on my application, and here it is how I solved it. It was actually quite simple.\r\n\r\nReading on the web about the problem, most people seem to be solving it by using `timeout=10`. Specifically my app runs on very old/cheap computers and this was simply not cutting. I needed to pass an absurdly large value to `timeout` to make it work, `timeout=100000`. \r\n\r\nIt did raise me the question, is timeout in seconds or milliseconds? I have a couple writes that take more than a second, and thought that setting it to `10` would solve the problem(becaus I thought it was 10 seconds), but it was only solved after it being larger than `1000`.\r\n\r\nKeep reading if you are using Qt.\r\n\r\nThis problem was terribly inconsistent for me, because somehow the way Qt handles its threads would prevent it from happening most of the time. And it was impossible to debug it, because I couldn't reproduce it whenever I wanted. The solution was also quite simple, create some python threads (not Qt threads), and run a bunch of concurrent writes, tweak the timeout number until it stops locking.\r\n\r\nHope this helps some other adventurous developers dealing with incredibly bad computers. ;)\r\n\r\n", "Thanks for bringing this to my attention. I've updated the interfaces and docs so that milliseconds are used everywhere: 171af17f5cced96c15d5e32e832474aa1618ab8c", "Sorry for necro but I think it's missed in a few places, unless that SqliteExtDatabase interface really does use seconds?\r\nhttps://docs.peewee-orm.com/en/latest/peewee/database.html\r\n\r\nEDIT: Also, this doesn't seem to be merged into master? Sorry if i'm asking something stupid here.\r\nhttps://github.com/coleifer/peewee/blob/master/peewee.py#L3416\r\n\r\nEDIT2: I see actually sqlite lists that timeout as seconds, so maybe it's correct now? Rather confusing", "That comment is outdated - seconds are used everywhere for sqlite timeouts." ]
2017-02-09T17:22:47
2021-06-02T12:47:39
2017-02-09T22:17:25
NONE
null
I am trying to insert multi threaded. I have 4 worker threads that pull data off a queue (producer/consumer model) and does an insert_many on that data. ```python def run(self): while True: try: r = self.q.get_nowait() except Empty: r = None if r is None: #TODO: signalling time.sleep(0.05) continue self.process(r) def process(self, item): table, data = item with db.transaction(): table.insert_many(data).execute() ``` Here is how I setup my connection: ```python db = SqliteDatabase(database, autocommit=False, threadlocals=True, pragmas=(('journal_mode', 'WAL'), ('cache_size', 10000))) ``` No matter how I set it up, I occasionally get `peewee.OperationalError: database is locked`. I am guessing that the insert_many is holding the lock too long, and a timeout is being hit. Am I doing this incorrectly or should I be somehow handling the database is locked error and retrying?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1188/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1188/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1187
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1187/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1187/comments
https://api.github.com/repos/coleifer/peewee/issues/1187/events
https://github.com/coleifer/peewee/issues/1187
206,420,069
MDU6SXNzdWUyMDY0MjAwNjk=
1,187
SQLite :memory: is not working in threads
{ "login": "charleschen", "id": 698190, "node_id": "MDQ6VXNlcjY5ODE5MA==", "avatar_url": "https://avatars.githubusercontent.com/u/698190?v=4", "gravatar_id": "", "url": "https://api.github.com/users/charleschen", "html_url": "https://github.com/charleschen", "followers_url": "https://api.github.com/users/charleschen/followers", "following_url": "https://api.github.com/users/charleschen/following{/other_user}", "gists_url": "https://api.github.com/users/charleschen/gists{/gist_id}", "starred_url": "https://api.github.com/users/charleschen/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/charleschen/subscriptions", "organizations_url": "https://api.github.com/users/charleschen/orgs", "repos_url": "https://api.github.com/users/charleschen/repos", "events_url": "https://api.github.com/users/charleschen/events{/privacy}", "received_events_url": "https://api.github.com/users/charleschen/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "In-memory databases only exist for the connection that opened them. Peewee, by default, uses a connection-per-thread, so each thread has it's own connection (and hence its own in-memory database). You can disable this by passing `threadlocals=False` to the db when initializing it. You might also need to pass `check_same_thread=False`, which is required to use pysqlite when you're sharing a connection across threads.", "thanks for the clarification!", "If i run this:\r\n```\r\ndb = SqliteDatabase(':memory:', threadlocals=False, check_same_thread=False)\r\n```\r\n\r\nI get:\r\n```\r\nTypeError: 'threadlocals' is an invalid keyword argument for this function\r\n```\r\n\r\nCan someone help me how to get it work?", "If you're using peewee 3.x, you do not need to pass the threadlocals keyword argument anymore. The error indicates this.", "But i have the same problem without passing it.", "You can use `thread_safe=False`. Sorry, I should have read the original issue description.\r\n\r\nIn 3.x, `thread_safe=True` means all threads have their own connection. You can pass `thread_safe=False` to make all your threads share the same connection to the underlying memory database." ]
2017-02-09T06:48:34
2018-04-03T12:11:20
2017-02-09T14:51:36
NONE
null
The following doesn't work: ``` import datetime import threading import time import peewee from playhouse import test_utils from playhouse import sqlite_ext db = sqlite_ext.SqliteExtDatabase('werd.sql') test_db = sqlite_ext.SqliteExtDatabase(':memory:') class SomeTable(peewee.Model): created_at = peewee.DateTimeField(default=datetime.datetime.now) class Meta: database = test_db threads = [] def worker(): print('db_instance', id(SomeTable._meta.database)) # same id here print('SomeTable count', SomeTable.select().count()) # will fail here return peewee.create_model_tables([SomeTable], fail_silently=True) SomeTable.create() print('db_instance', id(SomeTable._meta.database), SomeTable.select().count()) for i in range(2): t = threading.Thread(target=worker) threads.append(t) t.start() time.sleep(2) # just so we don't exit before the worker is done ``` is SQLite in memory not meant for threading?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1187/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1187/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1186
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1186/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1186/comments
https://api.github.com/repos/coleifer/peewee/issues/1186/events
https://github.com/coleifer/peewee/issues/1186
206,036,011
MDU6SXNzdWUyMDYwMzYwMTE=
1,186
autocommit should be True by default
{ "login": "benjsto", "id": 41104, "node_id": "MDQ6VXNlcjQxMTA0", "avatar_url": "https://avatars.githubusercontent.com/u/41104?v=4", "gravatar_id": "", "url": "https://api.github.com/users/benjsto", "html_url": "https://github.com/benjsto", "followers_url": "https://api.github.com/users/benjsto/followers", "following_url": "https://api.github.com/users/benjsto/following{/other_user}", "gists_url": "https://api.github.com/users/benjsto/gists{/gist_id}", "starred_url": "https://api.github.com/users/benjsto/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/benjsto/subscriptions", "organizations_url": "https://api.github.com/users/benjsto/orgs", "repos_url": "https://api.github.com/users/benjsto/repos", "events_url": "https://api.github.com/users/benjsto/events{/privacy}", "received_events_url": "https://api.github.com/users/benjsto/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "`autocommit` refers to the behavior of Peewee, not what the underlying driver may or may not be doing." ]
2017-02-07T22:27:04
2017-02-07T22:35:02
2017-02-07T22:35:02
NONE
null
As documented, and by my reading of the peewee source code, `autocommit` is intended to be True by default. However, that does not line up with what I'm seeing: Initializing a peewee MySQLDatabase instance: ``` db = MySQLDatabase(settings.get('db_name'), host=settings.get('db_host'), port=settings.get('db_port'), user=settings.get('db_user'), passwd=settings.get('db_pw'), charset='utf8mb4',) ``` Results in connections in the general log that look like: ``` 170207 22:01:58 1591 Connect [email protected] on test_db 1591 Query SET NAMES utf8mb4 1591 Query set autocommit=0 1591 Query SELECT `t1`.`id` FROM `table` AS t1 ORDER BY `t1`.`published_at` DESC LIMIT 1 OFFSET 0 1591 Query commit ``` I've found a workaround by subclassing MySQLDatabase and overriding the _connect method and explicitly passing in `autocommit=True` there.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1186/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1186/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1185
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1185/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1185/comments
https://api.github.com/repos/coleifer/peewee/issues/1185/events
https://github.com/coleifer/peewee/issues/1185
204,123,176
MDU6SXNzdWUyMDQxMjMxNzY=
1,185
Model to dict for array of models
{ "login": "theobouwman", "id": 16098190, "node_id": "MDQ6VXNlcjE2MDk4MTkw", "avatar_url": "https://avatars.githubusercontent.com/u/16098190?v=4", "gravatar_id": "", "url": "https://api.github.com/users/theobouwman", "html_url": "https://github.com/theobouwman", "followers_url": "https://api.github.com/users/theobouwman/followers", "following_url": "https://api.github.com/users/theobouwman/following{/other_user}", "gists_url": "https://api.github.com/users/theobouwman/gists{/gist_id}", "starred_url": "https://api.github.com/users/theobouwman/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/theobouwman/subscriptions", "organizations_url": "https://api.github.com/users/theobouwman/orgs", "repos_url": "https://api.github.com/users/theobouwman/repos", "events_url": "https://api.github.com/users/theobouwman/events{/privacy}", "received_events_url": "https://api.github.com/users/theobouwman/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Make a for loop. Jesus.", "Wauw" ]
2017-01-30T20:39:35
2017-01-30T21:21:18
2017-01-30T21:17:13
NONE
null
`model_to_dict` can only convert a single model to a dictionary, right? But what about an array of models, like this: `User.select().where(User.age > 19)` this will return all `users` above 19 years old. But what when I want to return this array as json? Then I need to loop through every object an make it a dictionary with `model_to_dict`. I find this pritty inconvenient to do when making an API. I know I can solve this by making a helper method, but I thought this should be in the core package. I can make a PR to add it to the playhouse module. Plz correct me if i'm wrong...
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1185/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1185/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1184
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1184/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1184/comments
https://api.github.com/repos/coleifer/peewee/issues/1184/events
https://github.com/coleifer/peewee/issues/1184
203,800,664
MDU6SXNzdWUyMDM4MDA2NjQ=
1,184
`execute_sql` seems not to respect `db.begin()`
{ "login": "kunalbhagawati", "id": 8683984, "node_id": "MDQ6VXNlcjg2ODM5ODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/8683984?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kunalbhagawati", "html_url": "https://github.com/kunalbhagawati", "followers_url": "https://api.github.com/users/kunalbhagawati/followers", "following_url": "https://api.github.com/users/kunalbhagawati/following{/other_user}", "gists_url": "https://api.github.com/users/kunalbhagawati/gists{/gist_id}", "starred_url": "https://api.github.com/users/kunalbhagawati/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kunalbhagawati/subscriptions", "organizations_url": "https://api.github.com/users/kunalbhagawati/orgs", "repos_url": "https://api.github.com/users/kunalbhagawati/repos", "events_url": "https://api.github.com/users/kunalbhagawati/events{/privacy}", "received_events_url": "https://api.github.com/users/kunalbhagawati/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Begin is a no-op on Postgres and MySQL because transaction handling is baked into the Python driver. Don't ask me why this is the case, it just is part of the DB-API 2.0. As you have found out, the way to manually perform a transaction is to turn off autocommit, then execute your queries and call commit manually when done (or rollback as the case may be). The atomic decorator/context manager does this as well.\r\n\r\nYou should be able to just:\r\n\r\n```\r\nwith db.atomic():\r\n db.execute_sql('UPDATE whatever')\r\n```" ]
2017-01-28T10:40:18
2017-01-30T19:25:54
2017-01-30T19:25:54
NONE
null
For the lack of time, I have put this in StackOverflow also. I hope that is okay. If its redundant, i'll remove it from there. http://stackoverflow.com/questions/41908762/using-transactions-with-peewee-without-using-atomic We have a file `db.py` where a peewee database is defined: db = PostgresqlExtDatabase('mom', user=DB_CONFIG['username'], password=DB_CONFIG['password'], host=DB_CONFIG['host'], port=DB_CONFIG['port'], threadlocals=True, register_hstore=False, autocommit=True, autorollback=True, cursor_factory=DictCursor) Calling `db.execute("SOME RAW SQL UPDATE QUERY")` works as expected. But calling a `begin` before that does not stop the DB from being modified. db.begin() db.execute("SOME RAW SQL UPDATE QUERY") # <- Does not wait, db is updated immediately here db.commit() Am i doing this right? I basically need to nest the raw sql in a transaction if one is already ongoing, else just execute it right away if there is no transaction `begin` called. This works as expected if i do `db.set_autocommit(False)` then `execute_sql` then `commit()`. It also works inside the `atomic()` context manager. --- To give some context, I am working on a web application, on logistics, and our codebase uses Flask and an SQLAlchemy `scoped_session` with `autocommit` set to True. It does not use the SQLAlchemy ORM (due to.. historical reasons) and instead just uses the `Session` object and its `execute()`, `begin()`, `begin_nested()`, `rollback()` and `remove()` methods. The way it does it is by defining a Session `Session = scoped_session(sessionmaker(autocommit=True))` in a file, and then calling `session = Session()` everywhere in the codebase, and executing the queries using `session.execute("SQL")` Sometimes, a `session.begin()` is called, so the query does not execute until the commit (or rollback). **We'd now really like to use peewee.** But.. the codebase is built on this session. So this has to be spoofed. Going and changing every file is impossible, and not enough test cases to boot (for.. historical reasons). --- Also I had some questions but I don't know where to ask them, so I hope you don't mind if I put them here: - Is this db object (and its connection) bound to the thread it is executing in? Basically will there be some bug if db is imported from two different files, and `db.begin()` is called from each? I can see in the ipython shell that the `id` for the `db` object above is the same per thread, so am I correct in assuming that unless the psycopg2 connection is recreated, this should be isolated? - To spoof the sqlalchemy `Session`, I have created a wrapper class that returns the kind of session required, the SQLA `Session` object, or the wrapper I've written for peewee to spoof that. class SessionMocker(object): # DO NOT make this a singleton. Sessions will break def __init__(self, orm_type=ORM_TYPES.SQLA): assert orm_type in ORM_TYPES, "Invalid session constructor type" super(SessionMocker, self).__init__() self.orm_type = orm_type def __call__(self, *args, **kwargs): if self.orm_type == ORM_TYPES.SQLA: return SQLASession(*args, **kwargs) if self.orm_type == ORM_TYPES.PEEWEE: # For now lets assume no slave return SessionWrapper(*args, **kwargs) raise NotImplementedError def __getattr__(self, item): """ Assuming this will never be called without calling Session() first. Else there is no way to tell what type of Session class (ORM) is required, since that can't be passed. """ if self.orm_type == ORM_TYPES.SQLA: kls = SQLASession elif self.orm_type == ORM_TYPES.PEEWEE: kls = SessionWrapper else: raise NotImplementedError return getattr(kls, item) Session = SessionMocker(ORM_TYPES.SQLA) I figured this will allow the codebase to make a transparent and seamless switch over to using peewee without having to change it everywhere. How can i do this in a better way?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1184/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1184/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1183
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1183/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1183/comments
https://api.github.com/repos/coleifer/peewee/issues/1183/events
https://github.com/coleifer/peewee/issues/1183
202,780,897
MDU6SXNzdWUyMDI3ODA4OTc=
1,183
Can we just remove Database.for_update Database.for_update_nowait ?
{ "login": "likang", "id": 850711, "node_id": "MDQ6VXNlcjg1MDcxMQ==", "avatar_url": "https://avatars.githubusercontent.com/u/850711?v=4", "gravatar_id": "", "url": "https://api.github.com/users/likang", "html_url": "https://github.com/likang", "followers_url": "https://api.github.com/users/likang/followers", "following_url": "https://api.github.com/users/likang/following{/other_user}", "gists_url": "https://api.github.com/users/likang/gists{/gist_id}", "starred_url": "https://api.github.com/users/likang/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/likang/subscriptions", "organizations_url": "https://api.github.com/users/likang/orgs", "repos_url": "https://api.github.com/users/likang/repos", "events_url": "https://api.github.com/users/likang/events{/privacy}", "received_events_url": "https://api.github.com/users/likang/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "These flags are used to indicate features supported by the db. They are used, for example, test_queries.py line 1867." ]
2017-01-24T10:36:46
2017-01-30T21:20:36
2017-01-30T21:20:36
NONE
null
It seems there is no references of them in peewee.py
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1183/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1183/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1182
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1182/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1182/comments
https://api.github.com/repos/coleifer/peewee/issues/1182/events
https://github.com/coleifer/peewee/issues/1182
202,034,288
MDU6SXNzdWUyMDIwMzQyODg=
1,182
"Using" is not thread safe.
{ "login": "fangchih", "id": 1895216, "node_id": "MDQ6VXNlcjE4OTUyMTY=", "avatar_url": "https://avatars.githubusercontent.com/u/1895216?v=4", "gravatar_id": "", "url": "https://api.github.com/users/fangchih", "html_url": "https://github.com/fangchih", "followers_url": "https://api.github.com/users/fangchih/followers", "following_url": "https://api.github.com/users/fangchih/following{/other_user}", "gists_url": "https://api.github.com/users/fangchih/gists{/gist_id}", "starred_url": "https://api.github.com/users/fangchih/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/fangchih/subscriptions", "organizations_url": "https://api.github.com/users/fangchih/orgs", "repos_url": "https://api.github.com/users/fangchih/repos", "events_url": "https://api.github.com/users/fangchih/events{/privacy}", "received_events_url": "https://api.github.com/users/fangchih/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Would this also happen if i running peewee in a multi-threaded web-server? I'm not familiar with concurrent programming.", "@chenbo515 I found this case only exists in below scenarios\r\n1) concurrent access to peewee model class. AND\r\n2) wanna use one peewee model class to access multiple databases which have same schema.", "You'll need to implement your own locking, unfortunately. Otherwise the `Using` blocks would need to add a lock. Something like this might work:\r\n\r\n```python\r\nfrom contextlib import contextmanager\r\n\r\ndb_lock = threading.Lock()\r\n\r\n@contextmanager\r\ndef ConcurrentUsing(*args):\r\n with db_lock:\r\n with Using(*args):\r\n yield\r\n```", "@coleifer thank you." ]
2017-01-20T02:42:40
2017-01-24T02:19:03
2017-01-23T21:37:06
NONE
null
Hi There, I have a requirement that needs to use one Model to deal with multiple Sqlite db files, and this process may execute concurrently, I did try the "Using" which get from [document]( http://docs.peewee-orm.com/en/latest/peewee/database.html#using-multiple-databases) but found the "Using" is not a thread-safe operation that I cannot confirm which db context will be during the runtime. May I know whether alternative solution existed? Fangchih. sample test code as below: ``` class RawData(BaseModel): dir_name = CharField() file_name = CharField() singer_name = CharField(null=True) song_name = CharField() class Meta: indexes = ( (('dir_name', 'file_name'), True), ) def _insert(db, data): print '_insert', db with Using(db, [RawData]): RawData.insert_many_test(data).execute() db1 = sqlitedatabase('tmp1.db') db2 = sqlitedatabase('tmp2.db') t1 = Thread(target=_insert, args=(db1, song_data[:9])) t2 = Thread(target=_insert, args=(db2, song_data[:7])) t1.start() t2.start() t1.join() t2.join() with Using(db1, [RawData]): cnt1 = RawData.select().count() self.assertEqual(cnt1, 9) with Using(self.db2, [RawData]): cnt2 = RawData.select().count() self.assertEqual(cnt2, 7) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1182/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1182/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1181
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1181/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1181/comments
https://api.github.com/repos/coleifer/peewee/issues/1181/events
https://github.com/coleifer/peewee/issues/1181
202,021,587
MDU6SXNzdWUyMDIwMjE1ODc=
1,181
fn.GROUP_CONCAT should support ORDER BY
{ "login": "mithmatt", "id": 5906984, "node_id": "MDQ6VXNlcjU5MDY5ODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/5906984?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mithmatt", "html_url": "https://github.com/mithmatt", "followers_url": "https://api.github.com/users/mithmatt/followers", "following_url": "https://api.github.com/users/mithmatt/following{/other_user}", "gists_url": "https://api.github.com/users/mithmatt/gists{/gist_id}", "starred_url": "https://api.github.com/users/mithmatt/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mithmatt/subscriptions", "organizations_url": "https://api.github.com/users/mithmatt/orgs", "repos_url": "https://api.github.com/users/mithmatt/repos", "events_url": "https://api.github.com/users/mithmatt/events{/privacy}", "received_events_url": "https://api.github.com/users/mithmatt/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Try this:\r\n\r\n```python\r\nfn.GROUP_CONCAT(Clause(\r\n SQL('Distinct'),\r\n MyModel.test_score,\r\n SQL('ORDER BY'),\r\n MyModel.test_score,\r\n SQL('DESC SEPARATOR \\' \\'')))\r\n```\r\n\r\nNot very clean but that should hopefully help you get the SQL you need." ]
2017-01-20T01:09:01
2017-01-23T21:41:40
2017-01-23T21:41:40
NONE
null
From [MySQL Docs](http://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html#function_group-concat), ```GROUP_CONCAT``` supports ```ORDER BY``` ``` mysql> SELECT student_name, -> GROUP_CONCAT(DISTINCT test_score -> ORDER BY test_score DESC SEPARATOR ' ') -> FROM student -> GROUP BY student_name; ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1181/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1181/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1180
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1180/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1180/comments
https://api.github.com/repos/coleifer/peewee/issues/1180/events
https://github.com/coleifer/peewee/issues/1180
201,600,862
MDU6SXNzdWUyMDE2MDA4NjI=
1,180
Postgresql FOR SHARE support
{ "login": "kapucko", "id": 2729306, "node_id": "MDQ6VXNlcjI3MjkzMDY=", "avatar_url": "https://avatars.githubusercontent.com/u/2729306?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kapucko", "html_url": "https://github.com/kapucko", "followers_url": "https://api.github.com/users/kapucko/followers", "following_url": "https://api.github.com/users/kapucko/following{/other_user}", "gists_url": "https://api.github.com/users/kapucko/gists{/gist_id}", "starred_url": "https://api.github.com/users/kapucko/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kapucko/subscriptions", "organizations_url": "https://api.github.com/users/kapucko/orgs", "repos_url": "https://api.github.com/users/kapucko/repos", "events_url": "https://api.github.com/users/kapucko/events{/privacy}", "received_events_url": "https://api.github.com/users/kapucko/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Added in 7f6f578f6f06e865ea5f3823c163d39aa6ff2a96\r\n\r\n```python\r\nSomeModel.select().with_lock('SHARE')\r\n```" ]
2017-01-18T15:12:18
2017-01-30T21:32:47
2017-01-30T21:32:47
NONE
null
Hi, I'm looking for support of FOR SHARE locking level in postgres (https://www.postgresql.org/docs/9.4/static/explicit-locking.html). I have found just this: http://docs.peewee-orm.com/en/latest/peewee/api.html#SelectQuery.for_update which generates FOR UPDATE. Is there any way I can implement this as an extension? Please help me. Thank you.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1180/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1180/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1179
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1179/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1179/comments
https://api.github.com/repos/coleifer/peewee/issues/1179/events
https://github.com/coleifer/peewee/issues/1179
201,546,904
MDU6SXNzdWUyMDE1NDY5MDQ=
1,179
how can use sub-table search?
{ "login": "noogel", "id": 8756485, "node_id": "MDQ6VXNlcjg3NTY0ODU=", "avatar_url": "https://avatars.githubusercontent.com/u/8756485?v=4", "gravatar_id": "", "url": "https://api.github.com/users/noogel", "html_url": "https://github.com/noogel", "followers_url": "https://api.github.com/users/noogel/followers", "following_url": "https://api.github.com/users/noogel/following{/other_user}", "gists_url": "https://api.github.com/users/noogel/gists{/gist_id}", "starred_url": "https://api.github.com/users/noogel/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/noogel/subscriptions", "organizations_url": "https://api.github.com/users/noogel/orgs", "repos_url": "https://api.github.com/users/noogel/repos", "events_url": "https://api.github.com/users/noogel/events{/privacy}", "received_events_url": "https://api.github.com/users/noogel/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is not a feature of peewee." ]
2017-01-18T11:25:31
2017-01-18T22:35:08
2017-01-18T22:35:08
NONE
null
I have many of the same tables, just different table names. like: book_001 book_002 ... ... book_100 How to write a Model class according to different conditions of the table data. E.g: Book.get_model('001').select().execute() => select * from book_001 Book.get_model('002').select().execute() => select * from book_002 How to implement the get_model() method. Thanks!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1179/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1179/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1178
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1178/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1178/comments
https://api.github.com/repos/coleifer/peewee/issues/1178/events
https://github.com/coleifer/peewee/issues/1178
201,529,821
MDU6SXNzdWUyMDE1Mjk4MjE=
1,178
Subquery problems with peewee Cython
{ "login": "danygielow", "id": 184562, "node_id": "MDQ6VXNlcjE4NDU2Mg==", "avatar_url": "https://avatars.githubusercontent.com/u/184562?v=4", "gravatar_id": "", "url": "https://api.github.com/users/danygielow", "html_url": "https://github.com/danygielow", "followers_url": "https://api.github.com/users/danygielow/followers", "following_url": "https://api.github.com/users/danygielow/following{/other_user}", "gists_url": "https://api.github.com/users/danygielow/gists{/gist_id}", "starred_url": "https://api.github.com/users/danygielow/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/danygielow/subscriptions", "organizations_url": "https://api.github.com/users/danygielow/orgs", "repos_url": "https://api.github.com/users/danygielow/repos", "events_url": "https://api.github.com/users/danygielow/events{/privacy}", "received_events_url": "https://api.github.com/users/danygielow/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Are you dead set on using `SQL('*')`? The \"peewee\" way would be to write:\r\n\r\n```python\r\nsub = sub.alias('sub')\r\nquery = A.select(sub.c.a, sub.c.b).from_(sub)\r\n```", "OK, you might be right. But there is still a discrepency in functionality between the Cython speedups and non-speedup code.\r\n\r\nI close this issue, because we will use the columns from now on." ]
2017-01-18T10:12:50
2017-01-24T09:54:14
2017-01-24T09:54:14
NONE
null
I have encountered an error with subqueries and the usage of `SQL('*')` when peewee is built with Cython extensions. Without Cython, the behavior is the same as before. TestCase: ```python def test_subselect(self): with test_database(self.mysql_test_db, [A]): A.create(a=1, b=3) A.create(a=2, b=4) sub = A.select(A.a, A.b) query = (A.select(peewee.SQL('*')).from_(sub.alias('sub'))) for r in query.dicts(): self.assertIn(r['a'], [1, 2]) self.assertIn(r['b'], [3, 4]) ``` Regardless, if the test is a representative example, it worked until version 2.8.4. This time I won't be able to supply a PR, because of my lack of C skills.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1178/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1178/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1177
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1177/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1177/comments
https://api.github.com/repos/coleifer/peewee/issues/1177/events
https://github.com/coleifer/peewee/issues/1177
201,424,757
MDU6SXNzdWUyMDE0MjQ3NTc=
1,177
Slow on iterating over simple query
{ "login": "GMaxera", "id": 3726196, "node_id": "MDQ6VXNlcjM3MjYxOTY=", "avatar_url": "https://avatars.githubusercontent.com/u/3726196?v=4", "gravatar_id": "", "url": "https://api.github.com/users/GMaxera", "html_url": "https://github.com/GMaxera", "followers_url": "https://api.github.com/users/GMaxera/followers", "following_url": "https://api.github.com/users/GMaxera/following{/other_user}", "gists_url": "https://api.github.com/users/GMaxera/gists{/gist_id}", "starred_url": "https://api.github.com/users/GMaxera/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/GMaxera/subscriptions", "organizations_url": "https://api.github.com/users/GMaxera/orgs", "repos_url": "https://api.github.com/users/GMaxera/repos", "events_url": "https://api.github.com/users/GMaxera/events{/privacy}", "received_events_url": "https://api.github.com/users/GMaxera/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It's Python...", "@coleifer, Please elaborate. \r\n\r\nI'm using peewee in cases where I am required to query 1 million or more rows.\r\n```python\r\nquery = table.select()\r\ndata = list(query.dicts())\r\n```\r\n\r\nThis process takes over 30s and when there are where clauses, it may take up to 1~2min.\r\n\r\nAre you saying there are no way to increase the performance of peewee or do you believe other libraries say sqlalchemy will also take the same amount of time?", "That's a shitcomment I made, must have been in a hurry or something, so apologies.\r\n\r\nThere's a short section in the docs about iterating over lots of rows: http://docs.peewee-orm.com/en/latest/peewee/querying.html#iterating-over-lots-of-rows\r\n\r\nThe key points are:\r\n\r\n* If you are doing a single-shot iteration and do not need to cache rows in memory, tack on a `.iterator()` to your query. This helps keep memory usage down for large result sets.\r\n* The fastest way to get lots of rows is to avoid creating expensive Python objects. Requesting that rows be returned as dicts, tuples or namedtuples is going to be fastest. If you have joins and are selecting from multiple models, you can also try using \".objects()\", which skips traversing the model graph. You can find examples here: http://docs.peewee-orm.com/en/latest/peewee/relationships.html#selecting-from-multiple-sources\r\n\r\nYou can compare the runtime of the query by itself versus the overhead of Peewee by using \"database.execute_sql(...)\", passing it a SQL string and a list of params. Alternatively, if you have a query object, you can use \"database.execute(query)\". These methods return a DB-API cursor which you can iterate over. This should give you a good baseline for how the query performs in Python.", "@coleifer thank you that you finally admitted that was shit comment. I was quite frustrated that you closed and dismissed my question as like I was stupid. Unfortunately, it's too late for me to use peewee again ... and at that time we decided to use PHP and now I'm working for another company :-)\r\n" ]
2017-01-17T22:30:11
2018-06-27T14:17:41
2017-01-23T21:42:32
NONE
null
I have this code: ```python tweetInsights = Gnip_Tweet_Insights \ .select() \ .where( (Gnip_Tweet_Insights.client_account_id==clientAccountId) & (Gnip_Tweet_Insights.occurred_at==insight.occurred_at) & (Gnip_Tweet_Insights.by_echomany==insight.by_echomany)) print( "After Query ", time.perf_counter() - startTime ) for singleInsight in tweetInsights: pass print( "After Dict ", time.perf_counter() - startTime ) ``` The query itself is very simple but contains 5000 rows. It takes less than 200 milliseconds if I do it with "Sequel Pro". But iterating over these 5000 rows using the "for singleInsight in tweetInsights:" takes around 1 seconds. And for my user case is too much. I don't understand why so long time for iterating over a 5000 rows. It's definitely not a large set of data. I tried using .naive(), .dicts() and .iterator() but none of these speed up the cycle. Is there something else I can use to speed up iterating ?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1177/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1177/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1176
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1176/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1176/comments
https://api.github.com/repos/coleifer/peewee/issues/1176/events
https://github.com/coleifer/peewee/pull/1176
201,356,019
MDExOlB1bGxSZXF1ZXN0MTAxOTExNjU5
1,176
Add full support for Postgres window functions
{ "login": "alin23", "id": 3819725, "node_id": "MDQ6VXNlcjM4MTk3MjU=", "avatar_url": "https://avatars.githubusercontent.com/u/3819725?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alin23", "html_url": "https://github.com/alin23", "followers_url": "https://api.github.com/users/alin23/followers", "following_url": "https://api.github.com/users/alin23/following{/other_user}", "gists_url": "https://api.github.com/users/alin23/gists{/gist_id}", "starred_url": "https://api.github.com/users/alin23/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alin23/subscriptions", "organizations_url": "https://api.github.com/users/alin23/orgs", "repos_url": "https://api.github.com/users/alin23/repos", "events_url": "https://api.github.com/users/alin23/events{/privacy}", "received_events_url": "https://api.github.com/users/alin23/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-01-17T17:38:57
2017-02-06T20:43:56
2017-02-06T20:43:56
NONE
null
* Add support for frame_clause ``` frame_clause can be one of { RANGE | ROWS } frame_start { RANGE | ROWS } BETWEEN frame_start AND frame_end where frame_start and frame_end can be one of UNBOUNDED PRECEDING value PRECEDING CURRENT ROW value FOLLOWING UNBOUNDED FOLLOWING ``` * Fix `WINDOW` clause positioning. Should be after `HAVING` * Allow non-list values for `partition_by` and `order_by`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1176/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1176/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1176", "html_url": "https://github.com/coleifer/peewee/pull/1176", "diff_url": "https://github.com/coleifer/peewee/pull/1176.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1176.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1175
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1175/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1175/comments
https://api.github.com/repos/coleifer/peewee/issues/1175/events
https://github.com/coleifer/peewee/issues/1175
201,291,192
MDU6SXNzdWUyMDEyOTExOTI=
1,175
Database default
{ "login": "theobouwman", "id": 16098190, "node_id": "MDQ6VXNlcjE2MDk4MTkw", "avatar_url": "https://avatars.githubusercontent.com/u/16098190?v=4", "gravatar_id": "", "url": "https://api.github.com/users/theobouwman", "html_url": "https://github.com/theobouwman", "followers_url": "https://api.github.com/users/theobouwman/followers", "following_url": "https://api.github.com/users/theobouwman/following{/other_user}", "gists_url": "https://api.github.com/users/theobouwman/gists{/gist_id}", "starred_url": "https://api.github.com/users/theobouwman/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/theobouwman/subscriptions", "organizations_url": "https://api.github.com/users/theobouwman/orgs", "repos_url": "https://api.github.com/users/theobouwman/repos", "events_url": "https://api.github.com/users/theobouwman/events{/privacy}", "received_events_url": "https://api.github.com/users/theobouwman/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yes, you can specify arbitrary stuff in the `constraints` field parameter:\r\n\r\n```python\r\ntimestamp = DateTimeField(constraints=[SQL('DEFAULT CURRENT_TIMESTAMP')])\r\n```\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/models.html?#default-field-values" ]
2017-01-17T13:56:05
2017-01-23T21:44:23
2017-01-23T21:44:23
NONE
null
Is it possible to add a default which is done by the database server. Like `DEFAULT CURRENT_TIMESTAMP` for a MySQL datetime field? I would like to make a PR if it's not available.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1175/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1175/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1174
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1174/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1174/comments
https://api.github.com/repos/coleifer/peewee/issues/1174/events
https://github.com/coleifer/peewee/issues/1174
201,110,650
MDU6SXNzdWUyMDExMTA2NTA=
1,174
Hug framework support
{ "login": "0gk", "id": 15966259, "node_id": "MDQ6VXNlcjE1OTY2MjU5", "avatar_url": "https://avatars.githubusercontent.com/u/15966259?v=4", "gravatar_id": "", "url": "https://api.github.com/users/0gk", "html_url": "https://github.com/0gk", "followers_url": "https://api.github.com/users/0gk/followers", "following_url": "https://api.github.com/users/0gk/following{/other_user}", "gists_url": "https://api.github.com/users/0gk/gists{/gist_id}", "starred_url": "https://api.github.com/users/0gk/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/0gk/subscriptions", "organizations_url": "https://api.github.com/users/0gk/orgs", "repos_url": "https://api.github.com/users/0gk/repos", "events_url": "https://api.github.com/users/0gk/events{/privacy}", "received_events_url": "https://api.github.com/users/0gk/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'd accept a PR with docs.", "Maybe something like this:\r\n\r\n```\r\[email protected]_middleware()\r\ndef preProcessing(request, response):\r\n db.connect()\r\n\r\[email protected]_middleware()\r\ndef afterProcessing(request, response, resource):\r\n db.close()\r\n```" ]
2017-01-16T20:20:20
2018-09-29T15:16:20
2017-01-23T21:42:52
NONE
null
Please, add section about Hug support. I try to use instructions for Falcon, but it don't work. May be Hug just have no hooks or smth like?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1174/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1174/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1173
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1173/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1173/comments
https://api.github.com/repos/coleifer/peewee/issues/1173/events
https://github.com/coleifer/peewee/pull/1173
200,589,838
MDExOlB1bGxSZXF1ZXN0MTAxNDE4MTAy
1,173
Fixed setting of compound parentheses, fixes #1168
{ "login": "danygielow", "id": 184562, "node_id": "MDQ6VXNlcjE4NDU2Mg==", "avatar_url": "https://avatars.githubusercontent.com/u/184562?v=4", "gravatar_id": "", "url": "https://api.github.com/users/danygielow", "html_url": "https://github.com/danygielow", "followers_url": "https://api.github.com/users/danygielow/followers", "following_url": "https://api.github.com/users/danygielow/following{/other_user}", "gists_url": "https://api.github.com/users/danygielow/gists{/gist_id}", "starred_url": "https://api.github.com/users/danygielow/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/danygielow/subscriptions", "organizations_url": "https://api.github.com/users/danygielow/orgs", "repos_url": "https://api.github.com/users/danygielow/repos", "events_url": "https://api.github.com/users/danygielow/events{/privacy}", "received_events_url": "https://api.github.com/users/danygielow/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I fixed this using slightly more compact code, hope it's more readable now." ]
2017-01-13T09:58:23
2017-01-13T22:27:28
2017-01-13T22:27:28
NONE
null
This PR fixes the issue in #1168 by only wrapping non-compound queries in parentheses. Changed the corresponding test as well.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1173/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1173/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1173", "html_url": "https://github.com/coleifer/peewee/pull/1173", "diff_url": "https://github.com/coleifer/peewee/pull/1173.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1173.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1172
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1172/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1172/comments
https://api.github.com/repos/coleifer/peewee/issues/1172/events
https://github.com/coleifer/peewee/issues/1172
200,575,641
MDU6SXNzdWUyMDA1NzU2NDE=
1,172
why there is no pskel?
{ "login": "axiaoxin", "id": 2876405, "node_id": "MDQ6VXNlcjI4NzY0MDU=", "avatar_url": "https://avatars.githubusercontent.com/u/2876405?v=4", "gravatar_id": "", "url": "https://api.github.com/users/axiaoxin", "html_url": "https://github.com/axiaoxin", "followers_url": "https://api.github.com/users/axiaoxin/followers", "following_url": "https://api.github.com/users/axiaoxin/following{/other_user}", "gists_url": "https://api.github.com/users/axiaoxin/gists{/gist_id}", "starred_url": "https://api.github.com/users/axiaoxin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/axiaoxin/subscriptions", "organizations_url": "https://api.github.com/users/axiaoxin/orgs", "repos_url": "https://api.github.com/users/axiaoxin/repos", "events_url": "https://api.github.com/users/axiaoxin/events{/privacy}", "received_events_url": "https://api.github.com/users/axiaoxin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It's only included in the git repo.", "Actually `pskel` is declared usign the `script=[]` parameter of `setup.py` installation script, which it fails on many occasions to properly install things.\r\n\r\nIt would work out of the box in all python environments if it was converted into console entry-point:\r\nhttp://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point\r\nSetuptools will generate an `.exe` on Windows, and guess correctly the path if python-interpreter on POSIX.\r\n\r\nI can provide a pull-request, but it would require some minor changes:\r\n- create new `main()` functions on `/pwiz.py` and `/playhouse/pskel`, \r\n- rename it as `pskel.py`.\r\n\r\nWould that be ok?\r\n" ]
2017-01-13T08:43:51
2017-10-10T15:39:36
2017-01-13T17:43:24
NONE
null
I read the doc: <http://docs.peewee-orm.com/en/latest/peewee/database.html#generating-skeleton-code>, I test using pskel to generate the skeleton code, but I found the pskel is not exists in my local under the site-packages, peewee's install-files.txt is: ``` ..\peewee.py ..\pwiz.py ..\playhouse\apsw_ext.py ..\playhouse\berkeleydb.py ..\playhouse\csv_loader.py ..\playhouse\csv_utils.py ..\playhouse\dataset.py ..\playhouse\db_url.py ..\playhouse\djpeewee.py ..\playhouse\fields.py ..\playhouse\flask_utils.py ..\playhouse\gfk.py ..\playhouse\hybrid.py ..\playhouse\kv.py ..\playhouse\migrate.py ..\playhouse\pool.py ..\playhouse\postgres_ext.py ..\playhouse\read_slave.py ..\playhouse\reflection.py ..\playhouse\shortcuts.py ..\playhouse\signals.py ..\playhouse\sqlcipher_ext.py ..\playhouse\sqliteq.py ..\playhouse\sqlite_ext.py ..\playhouse\sqlite_udf.py ..\playhouse\test_utils.py ..\playhouse\__init__.py ..\peewee.pyc ..\pwiz.pyc ..\playhouse\apsw_ext.pyc ..\playhouse\berkeleydb.pyc ..\playhouse\csv_loader.pyc ..\playhouse\csv_utils.pyc ..\playhouse\dataset.pyc ..\playhouse\db_url.pyc ..\playhouse\djpeewee.pyc ..\playhouse\fields.pyc ..\playhouse\flask_utils.pyc ..\playhouse\gfk.pyc ..\playhouse\hybrid.pyc ..\playhouse\kv.pyc ..\playhouse\migrate.pyc ..\playhouse\pool.pyc ..\playhouse\postgres_ext.pyc ..\playhouse\read_slave.pyc ..\playhouse\reflection.pyc ..\playhouse\shortcuts.pyc ..\playhouse\signals.pyc ..\playhouse\sqlcipher_ext.pyc ..\playhouse\sqliteq.pyc ..\playhouse\sqlite_ext.pyc ..\playhouse\sqlite_udf.pyc ..\playhouse\test_utils.pyc ..\playhouse\__init__.pyc dependency_links.txt PKG-INFO SOURCES.txt top_level.txt ..\..\..\Scripts\pwiz.py ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1172/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1172/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1171
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1171/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1171/comments
https://api.github.com/repos/coleifer/peewee/issues/1171/events
https://github.com/coleifer/peewee/pull/1171
200,222,783
MDExOlB1bGxSZXF1ZXN0MTAxMTU3Mjg4
1,171
Fix "derived" in api.rst.
{ "login": "cassidykelly", "id": 10568266, "node_id": "MDQ6VXNlcjEwNTY4MjY2", "avatar_url": "https://avatars.githubusercontent.com/u/10568266?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cassidykelly", "html_url": "https://github.com/cassidykelly", "followers_url": "https://api.github.com/users/cassidykelly/followers", "following_url": "https://api.github.com/users/cassidykelly/following{/other_user}", "gists_url": "https://api.github.com/users/cassidykelly/gists{/gist_id}", "starred_url": "https://api.github.com/users/cassidykelly/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cassidykelly/subscriptions", "organizations_url": "https://api.github.com/users/cassidykelly/orgs", "repos_url": "https://api.github.com/users/cassidykelly/repos", "events_url": "https://api.github.com/users/cassidykelly/events{/privacy}", "received_events_url": "https://api.github.com/users/cassidykelly/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-01-11T22:11:15
2017-01-12T00:08:07
2017-01-12T00:08:07
CONTRIBUTOR
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1171/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1171/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1171", "html_url": "https://github.com/coleifer/peewee/pull/1171", "diff_url": "https://github.com/coleifer/peewee/pull/1171.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1171.patch", "merged_at": "2017-01-12T00:08:07" }
https://api.github.com/repos/coleifer/peewee/issues/1170
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1170/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1170/comments
https://api.github.com/repos/coleifer/peewee/issues/1170/events
https://github.com/coleifer/peewee/issues/1170
200,185,022
MDU6SXNzdWUyMDAxODUwMjI=
1,170
Add view support to pwiz model generator
{ "login": "toddhay", "id": 1015217, "node_id": "MDQ6VXNlcjEwMTUyMTc=", "avatar_url": "https://avatars.githubusercontent.com/u/1015217?v=4", "gravatar_id": "", "url": "https://api.github.com/users/toddhay", "html_url": "https://github.com/toddhay", "followers_url": "https://api.github.com/users/toddhay/followers", "following_url": "https://api.github.com/users/toddhay/following{/other_user}", "gists_url": "https://api.github.com/users/toddhay/gists{/gist_id}", "starred_url": "https://api.github.com/users/toddhay/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/toddhay/subscriptions", "organizations_url": "https://api.github.com/users/toddhay/orgs", "repos_url": "https://api.github.com/users/toddhay/repos", "events_url": "https://api.github.com/users/toddhay/events{/privacy}", "received_events_url": "https://api.github.com/users/toddhay/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I do not have any plans for supporting this." ]
2017-01-11T19:28:10
2017-01-13T22:28:07
2017-01-13T22:28:07
NONE
null
Please add the ability to migrate database views to a model using the pwiz model generator capability. We're currently using postgresql and sqlite so those would be our initial database type requests. Thanks for the great peewee library, we use it heavily in our software development.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1170/reactions", "total_count": 2, "+1": 2, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1170/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1169
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1169/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1169/comments
https://api.github.com/repos/coleifer/peewee/issues/1169/events
https://github.com/coleifer/peewee/issues/1169
199,861,485
MDU6SXNzdWUxOTk4NjE0ODU=
1,169
Validation for choices in the application layer
{ "login": "ParthGandhi", "id": 819237, "node_id": "MDQ6VXNlcjgxOTIzNw==", "avatar_url": "https://avatars.githubusercontent.com/u/819237?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ParthGandhi", "html_url": "https://github.com/ParthGandhi", "followers_url": "https://api.github.com/users/ParthGandhi/followers", "following_url": "https://api.github.com/users/ParthGandhi/following{/other_user}", "gists_url": "https://api.github.com/users/ParthGandhi/gists{/gist_id}", "starred_url": "https://api.github.com/users/ParthGandhi/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ParthGandhi/subscriptions", "organizations_url": "https://api.github.com/users/ParthGandhi/orgs", "repos_url": "https://api.github.com/users/ParthGandhi/repos", "events_url": "https://api.github.com/users/ParthGandhi/events{/privacy}", "received_events_url": "https://api.github.com/users/ParthGandhi/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It can be validated in the application layer -- *your* application!", "Heh, we already do that! Was wondering if there was any interest upstream.\r\n\r\nThanks!" ]
2017-01-10T16:04:40
2017-01-11T16:53:30
2017-01-11T16:52:19
NONE
null
I get why you don't validate for `choices` in the db layer. Any reason it can't be implemented at the application layer? For backwards compatibility validated choices can be a new attribute called `allowed`/`validated_choices`? The behavior i'm thinking of is to throw a `ValueError` on saving a field if its not one of the allowed values.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1169/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1169/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1168
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1168/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1168/comments
https://api.github.com/repos/coleifer/peewee/issues/1168/events
https://github.com/coleifer/peewee/issues/1168
199,537,643
MDU6SXNzdWUxOTk1Mzc2NDM=
1,168
UNION with 3 or more queries leads to invalid SQL syntax (MySQL)
{ "login": "danygielow", "id": 184562, "node_id": "MDQ6VXNlcjE4NDU2Mg==", "avatar_url": "https://avatars.githubusercontent.com/u/184562?v=4", "gravatar_id": "", "url": "https://api.github.com/users/danygielow", "html_url": "https://github.com/danygielow", "followers_url": "https://api.github.com/users/danygielow/followers", "following_url": "https://api.github.com/users/danygielow/following{/other_user}", "gists_url": "https://api.github.com/users/danygielow/gists{/gist_id}", "starred_url": "https://api.github.com/users/danygielow/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/danygielow/subscriptions", "organizations_url": "https://api.github.com/users/danygielow/orgs", "repos_url": "https://api.github.com/users/danygielow/repos", "events_url": "https://api.github.com/users/danygielow/events{/privacy}", "received_events_url": "https://api.github.com/users/danygielow/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Fixed in d339c03. Thanks for the patch!" ]
2017-01-09T12:09:40
2017-01-13T22:27:47
2017-01-13T22:27:47
NONE
null
With the MysqlDatabase a UNION with 3 or more queries leads to a wrong syntax by wrapping individual UNION pairs in parentheses. I don't know if other databases are affected as well, SQLiteDatabase seems to work. Test Case: ```python class A(Model): id = PrimaryKeyField() b = IntegerField() class Meta(object): database = MySQLDatabase(MagicMock()) class TestPeeweeUnion(TestCase): def test_union(self): union = (A.select() | A.select() | A.select()) self.assertEqual('(SELECT `t1`.`id`, `t1`.`b` FROM `a` AS t1) UNION (SELECT `t2`.`id`, `t2`.`b` FROM `a` AS t2) UNION (SELECT `t3`.`id`, `t3`.`b` FROM `a` AS t3)', union.sql()[0]) ``` The assert fails because instead the following string is generated: ```sql ((SELECT `t1`.`id`, `t1`.`b` FROM `a` AS t1) UNION (SELECT `t2`.`id`, `t2`.`b` FROM `a` AS t2)) UNION (SELECT `t3`.`id`, `t3`.`b` FROM `a` AS t3) ``` The first pair of UNION is in parentheses. Affected Versions are 2.8.4 and 2.8.5. Thank you for looking into this. Edit: Judging by the test TestCompoundSelectSQL.test_multiple_with_parentheses this behavior is apparently desired. So in MySQL the parantheses should be set differently to the default.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1168/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1168/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1167
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1167/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1167/comments
https://api.github.com/repos/coleifer/peewee/issues/1167/events
https://github.com/coleifer/peewee/issues/1167
199,389,080
MDU6SXNzdWUxOTkzODkwODA=
1,167
Prefetch prefetches all foreign keys.
{ "login": "tkukushkin", "id": 1482516, "node_id": "MDQ6VXNlcjE0ODI1MTY=", "avatar_url": "https://avatars.githubusercontent.com/u/1482516?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tkukushkin", "html_url": "https://github.com/tkukushkin", "followers_url": "https://api.github.com/users/tkukushkin/followers", "following_url": "https://api.github.com/users/tkukushkin/following{/other_user}", "gists_url": "https://api.github.com/users/tkukushkin/gists{/gist_id}", "starred_url": "https://api.github.com/users/tkukushkin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tkukushkin/subscriptions", "organizations_url": "https://api.github.com/users/tkukushkin/orgs", "repos_url": "https://api.github.com/users/tkukushkin/repos", "events_url": "https://api.github.com/users/tkukushkin/events{/privacy}", "received_events_url": "https://api.github.com/users/tkukushkin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Unfortunately, prefetch cannot be lazy by definition. I'd suggest just writing the queries you need explicitly." ]
2017-01-07T22:29:33
2017-01-11T16:54:01
2017-01-11T16:54:01
NONE
null
I need to prefetch by only specific foreign key, but it prefetches by all. Maybe need to add possibility to specify field for prefetch instead of join_model? Also prefetch don't preserves by query methods like `Query.where` and it is not lazy. Maybe good to do query method like `Query.prefetch(self, *refs)` where `refs` – tuples like `(User.tweets, Tweet.select())` or simply `User.tweets`. This method will be lazy. Sorry for my English 😢.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1167/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1167/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1166
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1166/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1166/comments
https://api.github.com/repos/coleifer/peewee/issues/1166/events
https://github.com/coleifer/peewee/pull/1166
199,309,414
MDExOlB1bGxSZXF1ZXN0MTAwNTM5MDI1
1,166
Added missing word
{ "login": "egoberdon", "id": 4079351, "node_id": "MDQ6VXNlcjQwNzkzNTE=", "avatar_url": "https://avatars.githubusercontent.com/u/4079351?v=4", "gravatar_id": "", "url": "https://api.github.com/users/egoberdon", "html_url": "https://github.com/egoberdon", "followers_url": "https://api.github.com/users/egoberdon/followers", "following_url": "https://api.github.com/users/egoberdon/following{/other_user}", "gists_url": "https://api.github.com/users/egoberdon/gists{/gist_id}", "starred_url": "https://api.github.com/users/egoberdon/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/egoberdon/subscriptions", "organizations_url": "https://api.github.com/users/egoberdon/orgs", "repos_url": "https://api.github.com/users/egoberdon/repos", "events_url": "https://api.github.com/users/egoberdon/events{/privacy}", "received_events_url": "https://api.github.com/users/egoberdon/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-01-06T22:46:05
2017-01-09T21:26:20
2017-01-09T21:26:20
CONTRIBUTOR
null
Added a missing word
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1166/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1166/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1166", "html_url": "https://github.com/coleifer/peewee/pull/1166", "diff_url": "https://github.com/coleifer/peewee/pull/1166.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1166.patch", "merged_at": "2017-01-09T21:26:20" }
https://api.github.com/repos/coleifer/peewee/issues/1165
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1165/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1165/comments
https://api.github.com/repos/coleifer/peewee/issues/1165/events
https://github.com/coleifer/peewee/issues/1165
199,277,394
MDU6SXNzdWUxOTkyNzczOTQ=
1,165
Sqlite closure calls cannot reference each other
{ "login": "Naatan", "id": 278649, "node_id": "MDQ6VXNlcjI3ODY0OQ==", "avatar_url": "https://avatars.githubusercontent.com/u/278649?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Naatan", "html_url": "https://github.com/Naatan", "followers_url": "https://api.github.com/users/Naatan/followers", "following_url": "https://api.github.com/users/Naatan/following{/other_user}", "gists_url": "https://api.github.com/users/Naatan/gists{/gist_id}", "starred_url": "https://api.github.com/users/Naatan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Naatan/subscriptions", "organizations_url": "https://api.github.com/users/Naatan/orgs", "repos_url": "https://api.github.com/users/Naatan/repos", "events_url": "https://api.github.com/users/Naatan/events{/privacy}", "received_events_url": "https://api.github.com/users/Naatan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Anyone? I've been digging on this for a while myself now, but there is so much abstraction it's hard to figure out how to properly fix this.", "Looking at this now, sorry for the delays!", "Fixed -- Peewee was trying to be too clever by resolving the JOIN-ed closure table to a model instance and patching it to the place it was joined (the source table's primary key)." ]
2017-01-06T20:10:26
2017-01-30T21:53:30
2017-01-30T21:52:58
NONE
null
When you do a call to `descendants` or `ancestors` the returned model holds an id value that that is the Closure model, this makes it impossible to use this data in followup queries. Here's some code that illustrates the problem: ``` from peewee import * from playhouse.apsw_ext import * from playhouse.sqlite_ext import ClosureTable db = APSWDatabase(':memory:') db.load_extension("../env/lib/closure.so") class Symbol(Model): parent = ForeignKeyField('self', index=True, null=True) name = CharField() class Meta: database = db only_save_dirty = True SymbolClosure = ClosureTable(Symbol) db.create_tables([Symbol, SymbolClosure], True) symbol1 = Symbol.create(name="create_symbol_inherited_root") symbol2 = Symbol.create(name="create_symbol_inherited_root", parent=symbol1.id) symbol3 = Symbol.create(name="create_symbol_inherited_root", parent=symbol2.id) child1 = SymbolClosure.descendants(symbol1,1).first() print child1.id child2 = SymbolClosure.descendants(child1,1).first() print child2.id ``` The resulting output: ``` <peewee.SymbolClosure object at 0x7f85299a7990> Traceback (most recent call last): File "repro.py", line 28, in <module> child2 = SymbolClosure.descendants(child1,1).first() File "/home/nathan/Projects/codeintel/env/lib/python2.7/site-packages/peewee.py", line 3114, in first return self.peek(n=n) File "/home/nathan/Projects/codeintel/env/lib/python2.7/site-packages/peewee.py", line 3104, in peek res = self.execute() File "/home/nathan/Projects/codeintel/env/lib/python2.7/site-packages/peewee.py", line 3149, in execute self._qr = ResultWrapper(model_class, self._execute(), query_meta) File "/home/nathan/Projects/codeintel/env/lib/python2.7/site-packages/peewee.py", line 2833, in _execute return self.database.execute_sql(sql, params, self.require_commit) File "/home/nathan/Projects/codeintel/env/lib/python2.7/site-packages/playhouse/apsw_ext.py", line 116, in execute_sql self._execute_sql(cursor, sql, params) File "/home/nathan/Projects/codeintel/env/lib/python2.7/site-packages/playhouse/apsw_ext.py", line 109, in _execute_sql cursor.execute(sql, params or ()) TypeError: Bad binding argument type supplied - argument #1: type SymbolClosure ``` Note the first print (of `child.id`) is returning an instance of `peewee.SymbolClosure` rather than the actual id. This is the root of the problem.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1165/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1165/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1164
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1164/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1164/comments
https://api.github.com/repos/coleifer/peewee/issues/1164/events
https://github.com/coleifer/peewee/pull/1164
199,036,171
MDExOlB1bGxSZXF1ZXN0MTAwMzQ3MTAz
1,164
Allow recursive extra_attrs in model_to_dict.
{ "login": "cassidykelly", "id": 10568266, "node_id": "MDQ6VXNlcjEwNTY4MjY2", "avatar_url": "https://avatars.githubusercontent.com/u/10568266?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cassidykelly", "html_url": "https://github.com/cassidykelly", "followers_url": "https://api.github.com/users/cassidykelly/followers", "following_url": "https://api.github.com/users/cassidykelly/following{/other_user}", "gists_url": "https://api.github.com/users/cassidykelly/gists{/gist_id}", "starred_url": "https://api.github.com/users/cassidykelly/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cassidykelly/subscriptions", "organizations_url": "https://api.github.com/users/cassidykelly/orgs", "repos_url": "https://api.github.com/users/cassidykelly/repos", "events_url": "https://api.github.com/users/cassidykelly/events{/privacy}", "received_events_url": "https://api.github.com/users/cassidykelly/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Going to pass on this." ]
2017-01-05T19:18:05
2017-01-11T16:55:02
2017-01-11T16:55:02
CONTRIBUTOR
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1164/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1164/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1164", "html_url": "https://github.com/coleifer/peewee/pull/1164", "diff_url": "https://github.com/coleifer/peewee/pull/1164.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1164.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1163
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1163/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1163/comments
https://api.github.com/repos/coleifer/peewee/issues/1163/events
https://github.com/coleifer/peewee/issues/1163
199,014,459
MDU6SXNzdWUxOTkwMTQ0NTk=
1,163
Dicts not resolving join column name conflicts properly
{ "login": "jontonsoup", "id": 845636, "node_id": "MDQ6VXNlcjg0NTYzNg==", "avatar_url": "https://avatars.githubusercontent.com/u/845636?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jontonsoup", "html_url": "https://github.com/jontonsoup", "followers_url": "https://api.github.com/users/jontonsoup/followers", "following_url": "https://api.github.com/users/jontonsoup/following{/other_user}", "gists_url": "https://api.github.com/users/jontonsoup/gists{/gist_id}", "starred_url": "https://api.github.com/users/jontonsoup/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jontonsoup/subscriptions", "organizations_url": "https://api.github.com/users/jontonsoup/orgs", "repos_url": "https://api.github.com/users/jontonsoup/repos", "events_url": "https://api.github.com/users/jontonsoup/events{/privacy}", "received_events_url": "https://api.github.com/users/jontonsoup/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "How would it be automatically resolved? What would happen? How would Peewee pick one?\r\n\r\nThe answer you've come up with -- specifying an alias -- is the right approach.", "I'm not sure why you couldn't automatically prepend the name of the model infront of the column name and return both in cases where there is a clash.\n\nI've seen this in other ORMs I've used. The current behavior is dangerous because you don't know which column you are getting back and there are no warnings emitted. It fails silently. \n\nWhat do you think? \n\nOn Mon, Jan 09, 2017 at 4:25 PM Charles Leifer\n\n<\nmailto:Charles Leifer <[email protected]>\n> wrote:\n\na, pre, code, a:link, body { word-wrap: break-word !important; }\n\nClosed\nhttps://github.com/coleifer/peewee/issues/1163\n.\n\n—\n\nYou are receiving this because you authored the thread.\n\nReply to this email directly,\nhttps://github.com/coleifer/peewee/issues/1163#event-916600137\n, or\nhttps://github.com/notifications/unsubscribe-auth/AAznRLh5vOf5cpz7cudDbBGElQciGeUEks5rQqXAgaJpZM4Lb76I\n." ]
2017-01-05T17:36:05
2017-01-09T21:56:23
2017-01-09T21:25:17
NONE
null
Say I want to join three tables and two of the tables have the same column. ``` class Order(Model): status = Text.... class Betcycle(Model): status = Text.... ``` ``` rt_orders = list(Order.select(Order, RtPick, Betcycle).join( RtPick).join(Betcycle).where(Order.status == "SETTLED").dicts()) df_rt_orders = pd.DataFrame(rt_orders) ##use dict ``` The generated SQL will be correct (and will correctly call from the right table), but the retuning dict will only pick one of the `status` columns instead of alias them properly by table. I can do this: ``` Order.select(Order, Order.status.alias("order_status"), RtPick, Betcycle.status.alias("betcycle_status"))..... ``` but it seems like this can, and should be something that is automatically resolved. I can try to submit a pull request if you agree this is a problem
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1163/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1163/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1162
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1162/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1162/comments
https://api.github.com/repos/coleifer/peewee/issues/1162/events
https://github.com/coleifer/peewee/issues/1162
198,975,689
MDU6SXNzdWUxOTg5NzU2ODk=
1,162
Cascade delete is not working as expected
{ "login": "aellwein", "id": 3179781, "node_id": "MDQ6VXNlcjMxNzk3ODE=", "avatar_url": "https://avatars.githubusercontent.com/u/3179781?v=4", "gravatar_id": "", "url": "https://api.github.com/users/aellwein", "html_url": "https://github.com/aellwein", "followers_url": "https://api.github.com/users/aellwein/followers", "following_url": "https://api.github.com/users/aellwein/following{/other_user}", "gists_url": "https://api.github.com/users/aellwein/gists{/gist_id}", "starred_url": "https://api.github.com/users/aellwein/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/aellwein/subscriptions", "organizations_url": "https://api.github.com/users/aellwein/orgs", "repos_url": "https://api.github.com/users/aellwein/repos", "events_url": "https://api.github.com/users/aellwein/events{/privacy}", "received_events_url": "https://api.github.com/users/aellwein/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Looks like sqlite by default has foreign key support turned off:\r\n\r\nhttp://stackoverflow.com/a/13641365/724251\r\n\r\nNeed to add something like:\r\n\r\n```python\r\nTweet.raw(\"PRAGMA foreign_keys=ON\").execute()\r\n```\r\n\r\nMight be a nicer way included somewhere in the peewee docs.", "@alexlatchford \r\nthanks for pointing it out. \r\nSeems to be mentioned in the documentation, in http://docs.peewee-orm.com/en/latest/peewee/database.html?#additional-connection-initialization\r\n\r\nAlthough imho it is a little bit scary, that referential integrity is turned off by default.\r\n", "@aellwein -- don't use SQLite if you don't know how it works. Simple as that." ]
2017-01-05T15:01:28
2017-01-09T21:25:58
2017-01-09T21:25:58
NONE
null
Hi Charles, i created a table which is related to another table by a ForeignKeyField and on='CASCADE' policy in Sqlite. It seems like if i delete a record from the parent table, the children are not deleted. Here is a test that proves that behavior: https://gist.github.com/aellwein/9e814769196e5524e94199163aa4a0bd Am i doing something wrong? Thanks! Alex
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1162/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1162/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1161
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1161/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1161/comments
https://api.github.com/repos/coleifer/peewee/issues/1161/events
https://github.com/coleifer/peewee/issues/1161
198,857,436
MDU6SXNzdWUxOTg4NTc0MzY=
1,161
[Feature extension] Add in language option for postgres Match expressions
{ "login": "alexlatchford", "id": 628146, "node_id": "MDQ6VXNlcjYyODE0Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/628146?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexlatchford", "html_url": "https://github.com/alexlatchford", "followers_url": "https://api.github.com/users/alexlatchford/followers", "following_url": "https://api.github.com/users/alexlatchford/following{/other_user}", "gists_url": "https://api.github.com/users/alexlatchford/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexlatchford/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexlatchford/subscriptions", "organizations_url": "https://api.github.com/users/alexlatchford/orgs", "repos_url": "https://api.github.com/users/alexlatchford/repos", "events_url": "https://api.github.com/users/alexlatchford/events{/privacy}", "received_events_url": "https://api.github.com/users/alexlatchford/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Added in df65b09722bb14b884f89235e09709c4f398a7aa - thanks for your patience. Language is now an optional extra parameter to the `match` and `Match` functions.\r\n\r\n```python\r\nEntity.select().where(Match(Entity.display_name, prefix, 'english'))\r\n# or\r\nEntity.select().where(Entity.display_name.match(prefix, 'english'))\r\n```", "Excellent! Thanks @coleifer 🥇 " ]
2017-01-05T01:53:59
2017-01-30T21:59:36
2017-01-30T21:57:19
CONTRIBUTOR
null
Hey Charles, I've got a table I've just added fulltext search to, I've added a GIN index to speed up the query but looks like the `Match` expression in the `playhouse.postgres_ext` library isn't extensible enough to be able to make use of the index unfortunately. Table structure (simplified for brevity): ``` bash kb=> \d entity Table "public.entity" Column | Type | Modifiers -------------------+-----------------------------+----------- uuid | uuid | not null display_name | character varying(255) | not null Indexes: "entity_pkey" PRIMARY KEY, btree (uuid) "entity_display_name_idx" btree (display_name) "entity_full_text_search" gin (to_tsvector('english'::regconfig, display_name::text)) ``` Create index statement used (must specify language, get an error creating index if not. I'm running on Postgres 9.6): ```sql CREATE INDEX entity_full_text_search ON entity USING gin(to_tsvector('english', display_name)); ``` Peewee query: ```python Entity.select().where(Match(Entity.display_name, prefix)) ``` SQL peewee generates: ```sql kb=> explain analyze SELECT "t1"."uuid", "t1"."display_name" FROM "entity" AS t1 WHERE (to_tsvector("t1"."display_name") @@ to_tsquery('Jes')) LIMIT 50 OFFSET 0; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.00..5820.66 rows=50 width=82) (actual time=14.442..50535.567 rows=47 loops=1) -> Seq Scan on entity t1 (cost=0.00..3402640.35 rows=29229 width=82) (actual time=14.440..50535.486 rows=47 loops=1) Filter: (to_tsvector((display_name)::text) @@ to_tsquery('Jes'::text)) Rows Removed by Filter: 5847315 Planning time: 0.101 ms Execution time: 50535.627 ms ``` SQL needed to use GIN index (Change in `to_tsvector()`): ```sql kb=> explain analyze SELECT "t1"."uuid", "t1"."display_name" FROM "entity" AS t1 WHERE (to_tsvector('english', "t1"."display_name") @@ to_tsquery('Jes')) LIMIT 50 OFFSET 0; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=31.05..249.70 rows=50 width=82) (actual time=0.060..0.140 rows=47 loops=1) -> Bitmap Heap Scan on entity t1 (cost=31.05..3866.32 rows=877 width=82) (actual time=0.059..0.128 rows=47 loops=1) Recheck Cond: (to_tsvector('english'::regconfig, (display_name)::text) @@ to_tsquery('Jes'::text)) Heap Blocks: exact=47 -> Bitmap Index Scan on entity_full_text_search (cost=0.00..30.83 rows=877 width=0) (actual time=0.048..0.048 rows=47 loops=1) Index Cond: (to_tsvector('english'::regconfig, (display_name)::text) @@ to_tsquery('Jes'::text)) Planning time: 0.219 ms Execution time: 0.177 ms ``` Cheers, Alex PS. Just using a `SQL()` expression in the meantime :)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1161/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1161/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1160
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1160/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1160/comments
https://api.github.com/repos/coleifer/peewee/issues/1160/events
https://github.com/coleifer/peewee/issues/1160
198,652,615
MDU6SXNzdWUxOTg2NTI2MTU=
1,160
Add a new features for sql output.
{ "login": "b0123456789", "id": 21169660, "node_id": "MDQ6VXNlcjIxMTY5NjYw", "avatar_url": "https://avatars.githubusercontent.com/u/21169660?v=4", "gravatar_id": "", "url": "https://api.github.com/users/b0123456789", "html_url": "https://github.com/b0123456789", "followers_url": "https://api.github.com/users/b0123456789/followers", "following_url": "https://api.github.com/users/b0123456789/following{/other_user}", "gists_url": "https://api.github.com/users/b0123456789/gists{/gist_id}", "starred_url": "https://api.github.com/users/b0123456789/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/b0123456789/subscriptions", "organizations_url": "https://api.github.com/users/b0123456789/orgs", "repos_url": "https://api.github.com/users/b0123456789/repos", "events_url": "https://api.github.com/users/b0123456789/events{/privacy}", "received_events_url": "https://api.github.com/users/b0123456789/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-01-04T08:22:33
2017-01-09T21:23:12
2017-01-09T21:23:12
NONE
null
I use sql function to get a sql output,but i found that it display this **"('SELECT `t1`.`al_id`, `t1`.`al_uid` FROM `wyx_account_live` AS t1 WHERE ((`t1`.`al_id` > %s) AND (`t1`.`al_platform_type` = %s)) ORDER BY `t1`.`al_id` LIMIT 1', [31, 1])"**.but i hope it output this **"SELECT `t1`.`al_id`, `t1`.`al_uid` FROM `wyx_account_live` AS t1 WHERE ((`t1`.`al_id` > 31) AND (`t1`.`al_platform_type` = 1)) ORDER BY `t1`.`al_id` LIMIT 1"** to excute for mysql gui client to find out errers. Each time i should wirte **print(sql[0] % tuple(sql[1]))**,it really unfriendly. Is there a function? or can you add a function like that.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1160/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1160/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1159
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1159/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1159/comments
https://api.github.com/repos/coleifer/peewee/issues/1159/events
https://github.com/coleifer/peewee/issues/1159
198,388,213
MDU6SXNzdWUxOTgzODgyMTM=
1,159
create_or_get() uses AND instead of OR
{ "login": "tarashypka", "id": 15344666, "node_id": "MDQ6VXNlcjE1MzQ0NjY2", "avatar_url": "https://avatars.githubusercontent.com/u/15344666?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tarashypka", "html_url": "https://github.com/tarashypka", "followers_url": "https://api.github.com/users/tarashypka/followers", "following_url": "https://api.github.com/users/tarashypka/following{/other_user}", "gists_url": "https://api.github.com/users/tarashypka/gists{/gist_id}", "starred_url": "https://api.github.com/users/tarashypka/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tarashypka/subscriptions", "organizations_url": "https://api.github.com/users/tarashypka/orgs", "repos_url": "https://api.github.com/users/tarashypka/repos", "events_url": "https://api.github.com/users/tarashypka/events{/privacy}", "received_events_url": "https://api.github.com/users/tarashypka/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Looks like the 'get' part in 'create_or_get' uses 'AND' because at that point you would be trying to get a specific record, not a record that looks like the supplied parameters.\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/querying.html#create-or-get\r\n\r\nThe same is true for 'get_or_create', you want that specific record, not something that looks like it, and if it couldn't be found, create it.\r\n\r\nThat said, imagine if it used 'OR' instead and I was, for example, looking for a certain resident belonging to a certain address.\r\n\r\nResident.get((Resident.address == '123 Fake Street') | (Resident.name == 'John'))", "These methods use `and` because the Django APIs they are intended to mirror use that behavior. This isn't mongo." ]
2017-01-02T22:49:52
2017-01-03T21:17:52
2017-01-03T21:17:52
NONE
null
Currently, instead of ``` next_with_id, new = ProductCategory.create_or_get(**as_dict(next)) next.id = next_with_id.id next = next.parent if new else None ``` I am doing ``` try: with db.atomic(): next.save() next = next.parent except IntegrityError: next = ProductCategory.get( (ProductCategory.id == next.id) | # primary key (ProductCategory.name == next.name) | # unique field 1 (ProductCategory.cat_id == next.cat_id) # unique field 2 ) next = None ``` since the first variant produces > product.ProductCategoryDoesNotExist: Instance matching query does not exist: > SQL: SELECT "t1"."id", "t1"."name", "t1"."cat_id", "t1"."n_products", "t1"."n_pages", "t1"."parent_id" FROM "product_category" AS t1 WHERE ((("t1"."name" = %s) AND ("t1"."cat_id" = %s)) AND ("t1"."id" IS %s)) > PARAMS: [u'Appliances', u'4044_90548', None] Is there a particular reason why create_and_get() uses AND operator instead of OR operator? Because it could have been much easier to get documents by their unique fields yet without knowing their actual id values.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1159/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1159/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1158
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1158/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1158/comments
https://api.github.com/repos/coleifer/peewee/issues/1158/events
https://github.com/coleifer/peewee/issues/1158
198,025,671
MDU6SXNzdWUxOTgwMjU2NzE=
1,158
Join Query Scopes
{ "login": "jontonsoup", "id": 845636, "node_id": "MDQ6VXNlcjg0NTYzNg==", "avatar_url": "https://avatars.githubusercontent.com/u/845636?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jontonsoup", "html_url": "https://github.com/jontonsoup", "followers_url": "https://api.github.com/users/jontonsoup/followers", "following_url": "https://api.github.com/users/jontonsoup/following{/other_user}", "gists_url": "https://api.github.com/users/jontonsoup/gists{/gist_id}", "starred_url": "https://api.github.com/users/jontonsoup/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jontonsoup/subscriptions", "organizations_url": "https://api.github.com/users/jontonsoup/orgs", "repos_url": "https://api.github.com/users/jontonsoup/repos", "events_url": "https://api.github.com/users/jontonsoup/events{/privacy}", "received_events_url": "https://api.github.com/users/jontonsoup/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "As you said, your issue is a circular import. That's not really an issue peewee is designed to solve. In OO terms you probably need to add a third class that can read both modules and then route your access through that.", "@coleifer Thanks for taking a look at this!\r\n\r\nAre you familiar with active record? What I'm talking about is pretty common and is called an association scope.\r\n\r\nExamples: \r\n```\r\nbelongs_to :firm, -> { where(id: 2) }\r\nbelongs_to :user, -> { joins(:friends) }\r\nbelongs_to :level, ->(level) { where(\"game_level > ?\", level.current) }\r\n```\r\n\r\nhttp://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#label-Customizing+the+query\r\n\r\nThe way peewee seems to be designed makes it impossible to put an association scope in the class, but I'm really hoping that I am wrong here. \r\n\r\nDoes what I'm shooting for make more sense now? " ]
2016-12-29T15:39:03
2016-12-29T23:04:35
2016-12-29T22:13:22
NONE
null
Hi! I'm trying to put a where statement in a model class and use that in a relation as a scope. ``` class Pizza(Model): brand = ... blah blah @classmethod def where_cheddar(cls): return cls.toppings.where(Topping.type == "CHEDDAR") #HERE IS AN ERROR / CIRCULAR IMPORT class Topping(Model): pizza = ForeignKeyField(Pizza, related_name="toppings") type = Text.... def where_cheddar(self): return self.where(Topping.type = "CHEDDAR") ``` There are two ways I'd like to be able to do this: The first is less DRY but is the circular import above. If I skip the circular import and write this using the instance method for topping: ``` pizza = Pizza.select().first() pizza.toppings.where_cheddar() ``` I get a 'SelectQuery' object has no attribute where_cheddar error because the foreign key field relation returns a select query and where_cheddar operates on the Topping class. I'm sure there is a way to do this, but I must be missing something. Any help would be appreciated. Thanks! **EDIT:** I found model_class on SelectQuery, but this feels dirty. I would have to do: ``` return cls.toppings.where( cls.toppings.model_class.type == "CHEDDAR") ``` It violates the encapsulation of the Topping class.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1158/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1158/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1157
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1157/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1157/comments
https://api.github.com/repos/coleifer/peewee/issues/1157/events
https://github.com/coleifer/peewee/issues/1157
197,552,011
MDU6SXNzdWUxOTc1NTIwMTE=
1,157
multi-table join fail
{ "login": "argpass", "id": 16532113, "node_id": "MDQ6VXNlcjE2NTMyMTEz", "avatar_url": "https://avatars.githubusercontent.com/u/16532113?v=4", "gravatar_id": "", "url": "https://api.github.com/users/argpass", "html_url": "https://github.com/argpass", "followers_url": "https://api.github.com/users/argpass/followers", "following_url": "https://api.github.com/users/argpass/following{/other_user}", "gists_url": "https://api.github.com/users/argpass/gists{/gist_id}", "starred_url": "https://api.github.com/users/argpass/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/argpass/subscriptions", "organizations_url": "https://api.github.com/users/argpass/orgs", "repos_url": "https://api.github.com/users/argpass/repos", "events_url": "https://api.github.com/users/argpass/events{/privacy}", "received_events_url": "https://api.github.com/users/argpass/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee uses a concept called the \"query context\" when building joins. The model being selected, or the last model that was joined, is considered the context. A subsequent call to \".join()\" will be from the query context to the model indicated by the call to join().\r\n\r\nI think you just need to add the appropriate \".switch(ModelName)\" in between your joins to ensure that you're setting the appropriate query context. http://docs.peewee-orm.com/en/latest/peewee/api.html#Query.join\r\n\r\nAlso, why aren't you using any ForeignKeyFields?!" ]
2016-12-26T07:47:24
2016-12-27T16:43:40
2016-12-27T16:43:40
NONE
null
The `Car`: ![image](https://cloud.githubusercontent.com/assets/16532113/21478024/78359ffe-cb82-11e6-88b8-bdcb68e9c32e.png) The `Device`: ![image](https://cloud.githubusercontent.com/assets/16532113/21478012/623bedf2-cb82-11e6-9c35-729cd3713a4d.png) The `CarTerminal`: ![image](https://cloud.githubusercontent.com/assets/16532113/21477997/3946bb3e-cb82-11e6-97bc-cffbbb4a599e.png) here is right: ![image](https://cloud.githubusercontent.com/assets/16532113/21477992/2a728ebc-cb82-11e6-9a8f-91dd140d6ccb.png) ![image](https://cloud.githubusercontent.com/assets/16532113/21477940/98b6e7e8-cb81-11e6-8a94-a4d46c0c1eba.png) here is wrong: ![image](https://cloud.githubusercontent.com/assets/16532113/21478078/f2e3e4f4-cb82-11e6-9eed-df79940378ef.png) ![image](https://cloud.githubusercontent.com/assets/16532113/21478076/ea727c18-cb82-11e6-98d0-38291e1af3bf.png) here is also wrong, the sql is almost right without the fabricated `t2.id` ( CarTerminal has no field named `id` in fact ): ![image](https://cloud.githubusercontent.com/assets/16532113/21478253/6020ade4-cb84-11e6-9bb1-7944a68f5074.png) ![image](https://cloud.githubusercontent.com/assets/16532113/21478250/564fd772-cb84-11e6-96e9-588b6b169ceb.png)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1157/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1157/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1156
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1156/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1156/comments
https://api.github.com/repos/coleifer/peewee/issues/1156/events
https://github.com/coleifer/peewee/issues/1156
197,400,312
MDU6SXNzdWUxOTc0MDAzMTI=
1,156
insert_many is prohibitively slow. Provide options for fast execution.
{ "login": "bw2", "id": 6240170, "node_id": "MDQ6VXNlcjYyNDAxNzA=", "avatar_url": "https://avatars.githubusercontent.com/u/6240170?v=4", "gravatar_id": "", "url": "https://api.github.com/users/bw2", "html_url": "https://github.com/bw2", "followers_url": "https://api.github.com/users/bw2/followers", "following_url": "https://api.github.com/users/bw2/following{/other_user}", "gists_url": "https://api.github.com/users/bw2/gists{/gist_id}", "starred_url": "https://api.github.com/users/bw2/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/bw2/subscriptions", "organizations_url": "https://api.github.com/users/bw2/orgs", "repos_url": "https://api.github.com/users/bw2/repos", "events_url": "https://api.github.com/users/bw2/events{/privacy}", "received_events_url": "https://api.github.com/users/bw2/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm sorry you're finding it slow. The reasons for this will be apparent if you look into what the code is doing. There are quite a few small optimizations in there, but it'll never be close to as fast as just writing the SQL by hand and running it that way. Python's slow." ]
2016-12-23T16:59:14
2016-12-23T19:05:47
2016-12-23T19:05:47
NONE
null
I haven't looked into the cause in detail, but for a simple table with ~10 fields, running insert_many on batches of 1000 takes several times longer to run (even with validate_fields=False) than if I generate the sql query myself and run it with db.execute_sql. I can provide more details if needed, but if the reason is clear, it would be great to have additional args for insert_many that disable whatever extra steps it's doing and bring execution time down to the level of just concatenating strings and then running execute_sql.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1156/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1156/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1155
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1155/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1155/comments
https://api.github.com/repos/coleifer/peewee/issues/1155/events
https://github.com/coleifer/peewee/issues/1155
197,371,482
MDU6SXNzdWUxOTczNzE0ODI=
1,155
Error while Connecting using a Database URL
{ "login": "sonam0211", "id": 20140482, "node_id": "MDQ6VXNlcjIwMTQwNDgy", "avatar_url": "https://avatars.githubusercontent.com/u/20140482?v=4", "gravatar_id": "", "url": "https://api.github.com/users/sonam0211", "html_url": "https://github.com/sonam0211", "followers_url": "https://api.github.com/users/sonam0211/followers", "following_url": "https://api.github.com/users/sonam0211/following{/other_user}", "gists_url": "https://api.github.com/users/sonam0211/gists{/gist_id}", "starred_url": "https://api.github.com/users/sonam0211/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/sonam0211/subscriptions", "organizations_url": "https://api.github.com/users/sonam0211/orgs", "repos_url": "https://api.github.com/users/sonam0211/repos", "events_url": "https://api.github.com/users/sonam0211/events{/privacy}", "received_events_url": "https://api.github.com/users/sonam0211/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Could it have something to do with your connect statement?\r\n\r\n db = connect(os.environ.get('DATABASE_URL' or 'sqlite:///notes.db'))\r\n\r\nShould be:\r\n\r\n db = connect(os.environ.get('DATABASE_URL') or 'sqlite:///notes.db')", "@CorverDevelopment has it." ]
2016-12-23T13:43:17
2016-12-23T19:06:21
2016-12-23T19:06:21
NONE
null
app.py ``` app = Flask(__name__) bootstrap = Bootstrap(app) def setup_db(): create_model_tables([User, Notepad], fail_silently=True) if __name__ == '__main__': setup_db() app.secret_key = 'super_secret_key' app.run(debug=True) ``` Model.py ``` import os from peewee import Model, CharField, SqliteDatabase, CharField, ForeignKeyField, IntegrityError from playhouse.db_url import connect db = connect(os.environ.get('DATABASE_URL' or 'sqlite:///notes.db')) class BaseModel(Model): class Meta: database = db class User(BaseModel): .... class Notepad(BaseModel): .... ``` Error ``` Traceback (most recent call last): File "app.py", line 1, in <module> from model import User, Notepad File "/Users/rahul/projects/personal/Online-Notes/model.py", line 33, in <module> db = connect(os.environ.get('DATABASE_URL' or 'sqlite:///notes.db')) File "/Users/rahul/.virtualenvs/Online-Notes/lib/python2.7/site-packages/playhouse/db_url.py", line 84, in connect parsed = urlparse(url) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 143, in urlparse tuple = urlsplit(url, scheme, allow_fragments) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 182, in urlsplit i = url.find(':') AttributeError: 'NoneType' object has no attribute 'find' ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1155/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1155/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1154
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1154/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1154/comments
https://api.github.com/repos/coleifer/peewee/issues/1154/events
https://github.com/coleifer/peewee/pull/1154
197,085,923
MDExOlB1bGxSZXF1ZXN0OTkwNDI1MDY=
1,154
Small sentence correction
{ "login": "LuckyURE", "id": 1676008, "node_id": "MDQ6VXNlcjE2NzYwMDg=", "avatar_url": "https://avatars.githubusercontent.com/u/1676008?v=4", "gravatar_id": "", "url": "https://api.github.com/users/LuckyURE", "html_url": "https://github.com/LuckyURE", "followers_url": "https://api.github.com/users/LuckyURE/followers", "following_url": "https://api.github.com/users/LuckyURE/following{/other_user}", "gists_url": "https://api.github.com/users/LuckyURE/gists{/gist_id}", "starred_url": "https://api.github.com/users/LuckyURE/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/LuckyURE/subscriptions", "organizations_url": "https://api.github.com/users/LuckyURE/orgs", "repos_url": "https://api.github.com/users/LuckyURE/repos", "events_url": "https://api.github.com/users/LuckyURE/events{/privacy}", "received_events_url": "https://api.github.com/users/LuckyURE/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thank you!" ]
2016-12-22T03:18:10
2016-12-23T19:12:10
2016-12-23T19:12:07
CONTRIBUTOR
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1154/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1154/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1154", "html_url": "https://github.com/coleifer/peewee/pull/1154", "diff_url": "https://github.com/coleifer/peewee/pull/1154.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1154.patch", "merged_at": "2016-12-23T19:12:07" }
https://api.github.com/repos/coleifer/peewee/issues/1153
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1153/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1153/comments
https://api.github.com/repos/coleifer/peewee/issues/1153/events
https://github.com/coleifer/peewee/pull/1153
196,813,431
MDExOlB1bGxSZXF1ZXN0OTg4NDkxOTk=
1,153
Add support for ON CONFLICT DO NOTHING in Postgres.
{ "login": "cassidykelly", "id": 10568266, "node_id": "MDQ6VXNlcjEwNTY4MjY2", "avatar_url": "https://avatars.githubusercontent.com/u/10568266?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cassidykelly", "html_url": "https://github.com/cassidykelly", "followers_url": "https://api.github.com/users/cassidykelly/followers", "following_url": "https://api.github.com/users/cassidykelly/following{/other_user}", "gists_url": "https://api.github.com/users/cassidykelly/gists{/gist_id}", "starred_url": "https://api.github.com/users/cassidykelly/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cassidykelly/subscriptions", "organizations_url": "https://api.github.com/users/cassidykelly/orgs", "repos_url": "https://api.github.com/users/cassidykelly/repos", "events_url": "https://api.github.com/users/cassidykelly/events{/privacy}", "received_events_url": "https://api.github.com/users/cassidykelly/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Will this get merged? Any obvious show-stoppers?", "Full support for ON CONFLICT is pretty complex. Take a look at this: https://www.postgresql.org/docs/9.5/static/sql-insert.html", "This feels like a stop-gap implementation. I'd prefer t be comprehensive in implementing this feature, so I'm closing this." ]
2016-12-21T00:06:06
2017-05-23T04:00:51
2017-05-23T04:00:51
CONTRIBUTOR
null
I saw in the documentation there is a plan to add support for Postgres 9.5's ON CONFLICT DO UPDATE (i.e. upsert), but I didn't see any mention of ON CONFLICT DO NOTHING. This is one simple way to support the latter, although it does not support adding a **_conflict_target_**.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1153/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1153/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1153", "html_url": "https://github.com/coleifer/peewee/pull/1153", "diff_url": "https://github.com/coleifer/peewee/pull/1153.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1153.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1152
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1152/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1152/comments
https://api.github.com/repos/coleifer/peewee/issues/1152/events
https://github.com/coleifer/peewee/pull/1152
196,602,612
MDExOlB1bGxSZXF1ZXN0OTg2OTc3ODI=
1,152
Update playhouse.rst
{ "login": "alprotasov", "id": 7497700, "node_id": "MDQ6VXNlcjc0OTc3MDA=", "avatar_url": "https://avatars.githubusercontent.com/u/7497700?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alprotasov", "html_url": "https://github.com/alprotasov", "followers_url": "https://api.github.com/users/alprotasov/followers", "following_url": "https://api.github.com/users/alprotasov/following{/other_user}", "gists_url": "https://api.github.com/users/alprotasov/gists{/gist_id}", "starred_url": "https://api.github.com/users/alprotasov/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alprotasov/subscriptions", "organizations_url": "https://api.github.com/users/alprotasov/orgs", "repos_url": "https://api.github.com/users/alprotasov/repos", "events_url": "https://api.github.com/users/alprotasov/events{/privacy}", "received_events_url": "https://api.github.com/users/alprotasov/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-12-20T07:16:27
2017-01-09T21:19:56
2017-01-09T21:19:56
CONTRIBUTOR
null
Misspelling in extension
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1152/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1152/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1152", "html_url": "https://github.com/coleifer/peewee/pull/1152", "diff_url": "https://github.com/coleifer/peewee/pull/1152.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1152.patch", "merged_at": "2017-01-09T21:19:56" }
https://api.github.com/repos/coleifer/peewee/issues/1151
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1151/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1151/comments
https://api.github.com/repos/coleifer/peewee/issues/1151/events
https://github.com/coleifer/peewee/issues/1151
196,415,184
MDU6SXNzdWUxOTY0MTUxODQ=
1,151
There is no ID field in my table why select will default with it
{ "login": "amosnothing", "id": 24653016, "node_id": "MDQ6VXNlcjI0NjUzMDE2", "avatar_url": "https://avatars.githubusercontent.com/u/24653016?v=4", "gravatar_id": "", "url": "https://api.github.com/users/amosnothing", "html_url": "https://github.com/amosnothing", "followers_url": "https://api.github.com/users/amosnothing/followers", "following_url": "https://api.github.com/users/amosnothing/following{/other_user}", "gists_url": "https://api.github.com/users/amosnothing/gists{/gist_id}", "starred_url": "https://api.github.com/users/amosnothing/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/amosnothing/subscriptions", "organizations_url": "https://api.github.com/users/amosnothing/orgs", "repos_url": "https://api.github.com/users/amosnothing/repos", "events_url": "https://api.github.com/users/amosnothing/events{/privacy}", "received_events_url": "https://api.github.com/users/amosnothing/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-12-19T13:36:57
2016-12-20T02:55:09
2016-12-20T02:55:09
NONE
null
# my code class user_account(Model): user_no = BigIntegerField() amount = DecimalField() frozen_amount = DecimalField() create_time = DateTimeField() creator = CharField() edit_time = DateTimeField() editor = CharField() is_del = BooleanField() version = CharField() class Meta: database = db db.connect() print user_account.select() ------------------------- then you will see: <class '__main__.user_account'> SELECT **"t1"."id"**, "t1"."user_no", "t1"."amount", "t1"."frozen_amount", "t1"."create_time", "t1"."creator", "t1"."edit_time", "t1"."editor", "t1"."is_del", "t1"."version" FROM "user_account" AS t1 [] but there is no id fieid in my table.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1151/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1151/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1150
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1150/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1150/comments
https://api.github.com/repos/coleifer/peewee/issues/1150/events
https://github.com/coleifer/peewee/issues/1150
196,167,048
MDU6SXNzdWUxOTYxNjcwNDg=
1,150
Float gets autoconverted into integer in query
{ "login": "Budovi", "id": 23473432, "node_id": "MDQ6VXNlcjIzNDczNDMy", "avatar_url": "https://avatars.githubusercontent.com/u/23473432?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Budovi", "html_url": "https://github.com/Budovi", "followers_url": "https://api.github.com/users/Budovi/followers", "following_url": "https://api.github.com/users/Budovi/following{/other_user}", "gists_url": "https://api.github.com/users/Budovi/gists{/gist_id}", "starred_url": "https://api.github.com/users/Budovi/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Budovi/subscriptions", "organizations_url": "https://api.github.com/users/Budovi/orgs", "repos_url": "https://api.github.com/users/Budovi/repos", "events_url": "https://api.github.com/users/Budovi/events{/privacy}", "received_events_url": "https://api.github.com/users/Budovi/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nice catch.", "There have been issues raised in the past due to the opposite being the case -- Peewee was *not* converting the value on the right-hand-side to the appropriate data-type. The fix is pretty simple:\r\n\r\n```python\r\nfrom peewee import Passthrough\r\n\r\nTable.select().where(Table.foo * Passthrough(0.5) > Table.bar).get()\r\n```" ]
2016-12-16T22:21:20
2016-12-23T19:11:01
2016-12-23T19:11:01
NONE
null
The following code: ```python import peeweee db = peewee.SqliteDatabase(None) class Table(peewee.Model): id = peewee.PrimaryKeyField() foo = peewee.IntegerField() bar = peewee.IntegerField() class Meta: database = db db.init("test.db") db.connect() db.create_tables([Table]) Table.create(foo=10, bar=3) Table.select().where(Table.foo * 0.5 > Table.bar).get() ``` Raises the following exception: ```python Traceback (most recent call last): File "/home/budovi/.local/lib/python3.5/site-packages/peewee.py", line 3097, in get return next(clone.execute()) File "/home/budovi/.local/lib/python3.5/site-packages/peewee.py", line 2271, in next obj = self.iterate() File "/home/budovi/.local/lib/python3.5/site-packages/peewee.py", line 2253, in iterate raise StopIteration StopIteration During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/budovi/.local/lib/python3.5/site-packages/peewee.py", line 3101, in get % self.sql()) __main__.TableDoesNotExist: Instance matching query does not exist: SQL: SELECT "t1"."id", "t1"."foo", "t1"."bar" FROM "table" AS t1 WHERE (("t1"."foo" * ?) > "t1"."bar") PARAMS: [0] ``` Note the parameters passed to the query. The float got converted to integer. This is inconsistent with shell behaviour: ``` $ sqlite3 test.db sqlite> SELECT * FROM `Table` WHERE `foo` * 0.5 > `bar`; 1|10|3 ``` and comparison / multiplication is defined with numeric types just fine (https://www.sqlite.org/datatype3.html).
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1150/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1150/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1149
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1149/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1149/comments
https://api.github.com/repos/coleifer/peewee/issues/1149/events
https://github.com/coleifer/peewee/issues/1149
195,984,254
MDU6SXNzdWUxOTU5ODQyNTQ=
1,149
MySQLDatabase object has no attribute '_meta'
{ "login": "ambross", "id": 19628961, "node_id": "MDQ6VXNlcjE5NjI4OTYx", "avatar_url": "https://avatars.githubusercontent.com/u/19628961?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ambross", "html_url": "https://github.com/ambross", "followers_url": "https://api.github.com/users/ambross/followers", "following_url": "https://api.github.com/users/ambross/following{/other_user}", "gists_url": "https://api.github.com/users/ambross/gists{/gist_id}", "starred_url": "https://api.github.com/users/ambross/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ambross/subscriptions", "organizations_url": "https://api.github.com/users/ambross/orgs", "repos_url": "https://api.github.com/users/ambross/repos", "events_url": "https://api.github.com/users/ambross/events{/privacy}", "received_events_url": "https://api.github.com/users/ambross/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Hello should subclass Model, not your database instance." ]
2016-12-16T05:32:39
2016-12-16T15:18:01
2016-12-16T15:18:01
NONE
null
This is my simple code ``` from peewee import * db = MySQLDatabase('peeweetest',host='localhost',port=3306,user='root',passwd='****') class Hello(db): name = CharField() age = CharField() class Meta: database = db db.connect() db.create_table(Hello,safe=True) ``` When I run this I get ``` Traceback (most recent call last): File "tm.py", line 13, in <module> db.create_table(Hello,safe=True) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3769, in create_table return self.execute_sql(*qc.create_table(model_class, safe)) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2084, in inner return self.parse_node(fn(*args, **kwargs)) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2103, in _create_table meta = model_class._meta AttributeError: 'MySQLDatabase' object has no attribute '_meta' ``` peewee version 2.8.5
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1149/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1149/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1148
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1148/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1148/comments
https://api.github.com/repos/coleifer/peewee/issues/1148/events
https://github.com/coleifer/peewee/issues/1148
195,932,995
MDU6SXNzdWUxOTU5MzI5OTU=
1,148
Schema migrations don't create indexes
{ "login": "alexlatchford", "id": 628146, "node_id": "MDQ6VXNlcjYyODE0Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/628146?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexlatchford", "html_url": "https://github.com/alexlatchford", "followers_url": "https://api.github.com/users/alexlatchford/followers", "following_url": "https://api.github.com/users/alexlatchford/following{/other_user}", "gists_url": "https://api.github.com/users/alexlatchford/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexlatchford/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexlatchford/subscriptions", "organizations_url": "https://api.github.com/users/alexlatchford/orgs", "repos_url": "https://api.github.com/users/alexlatchford/repos", "events_url": "https://api.github.com/users/alexlatchford/events{/privacy}", "received_events_url": "https://api.github.com/users/alexlatchford/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The code to add an index is tested, so I believe adding an index explicitly should work. You can check the `test_add_index` test-case in `test_migrate.py`.", "Call Model.create_table(). ", "Or, oddly, database.create_tables([Model]). The database.create_table method will only create the table, though, whereas create_tables() creates both tables and indexes.", "I've tested this with v2.8.6 and definitely fixed for the schema migration utils", "@coleifer Yes sorry I removed my comment without updating.\r\n\r\n`database.create_tables([])` do create both table and indexes but `database.create_table` does not." ]
2016-12-15T22:27:49
2017-02-27T18:57:29
2016-12-30T22:06:36
CONTRIBUTOR
null
If you're doing a migration and add a column with `index=True` or `unique=True` it doesn't automatically create an index. Even trying to perform a `migrator.add_index()` in the same `migrate()` block fails. I'm doing this with the Postgres backend.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1148/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1148/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1147
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1147/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1147/comments
https://api.github.com/repos/coleifer/peewee/issues/1147/events
https://github.com/coleifer/peewee/issues/1147
195,645,181
MDU6SXNzdWUxOTU2NDUxODE=
1,147
Where is ClosureTable?
{ "login": "Naatan", "id": 278649, "node_id": "MDQ6VXNlcjI3ODY0OQ==", "avatar_url": "https://avatars.githubusercontent.com/u/278649?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Naatan", "html_url": "https://github.com/Naatan", "followers_url": "https://api.github.com/users/Naatan/followers", "following_url": "https://api.github.com/users/Naatan/following{/other_user}", "gists_url": "https://api.github.com/users/Naatan/gists{/gist_id}", "starred_url": "https://api.github.com/users/Naatan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Naatan/subscriptions", "organizations_url": "https://api.github.com/users/Naatan/orgs", "repos_url": "https://api.github.com/users/Naatan/repos", "events_url": "https://api.github.com/users/Naatan/events{/privacy}", "received_events_url": "https://api.github.com/users/Naatan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I found the problem, seems ClosureTable does not get defined when using apsw_ext. I'll close this and refile if I find I can't use it from sqlite_ext." ]
2016-12-14T21:03:52
2016-12-14T21:09:53
2016-12-14T21:09:45
NONE
null
See docs: http://docs.peewee-orm.com/en/latest/peewee/playhouse.html?highlight=apsw#ClosureTable ClosureTable is not defined. Using it produces an "is not defined" error.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1147/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1147/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1146
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1146/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1146/comments
https://api.github.com/repos/coleifer/peewee/issues/1146/events
https://github.com/coleifer/peewee/issues/1146
195,023,258
MDU6SXNzdWUxOTUwMjMyNTg=
1,146
Documentation on Extensions?
{ "login": "Naatan", "id": 278649, "node_id": "MDQ6VXNlcjI3ODY0OQ==", "avatar_url": "https://avatars.githubusercontent.com/u/278649?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Naatan", "html_url": "https://github.com/Naatan", "followers_url": "https://api.github.com/users/Naatan/followers", "following_url": "https://api.github.com/users/Naatan/following{/other_user}", "gists_url": "https://api.github.com/users/Naatan/gists{/gist_id}", "starred_url": "https://api.github.com/users/Naatan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Naatan/subscriptions", "organizations_url": "https://api.github.com/users/Naatan/orgs", "repos_url": "https://api.github.com/users/Naatan/repos", "events_url": "https://api.github.com/users/Naatan/events{/privacy}", "received_events_url": "https://api.github.com/users/Naatan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nevermind, it's there. The header style was throwing me off." ]
2016-12-12T16:42:24
2016-12-12T17:19:51
2016-12-12T17:19:50
NONE
null
I'm interested in SQLITE FTS4, FTS5 and closure tables. Peewee [states to have some form of support for them](http://docs.peewee-orm.com/en/latest/peewee/playhouse.html?highlight=closure#sqlite-ext). However, that's the only mention I see. Are there no docs on what this support actually entails and how I use it? How would I go about taking advantage of Peewee's "support" for these features?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1146/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1146/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1145
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1145/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1145/comments
https://api.github.com/repos/coleifer/peewee/issues/1145/events
https://github.com/coleifer/peewee/pull/1145
194,868,310
MDExOlB1bGxSZXF1ZXN0OTc0ODAwMjk=
1,145
Remove join predicate requirement for cross joins.
{ "login": "cassidykelly", "id": 10568266, "node_id": "MDQ6VXNlcjEwNTY4MjY2", "avatar_url": "https://avatars.githubusercontent.com/u/10568266?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cassidykelly", "html_url": "https://github.com/cassidykelly", "followers_url": "https://api.github.com/users/cassidykelly/followers", "following_url": "https://api.github.com/users/cassidykelly/following{/other_user}", "gists_url": "https://api.github.com/users/cassidykelly/gists{/gist_id}", "starred_url": "https://api.github.com/users/cassidykelly/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cassidykelly/subscriptions", "organizations_url": "https://api.github.com/users/cassidykelly/orgs", "repos_url": "https://api.github.com/users/cassidykelly/repos", "events_url": "https://api.github.com/users/cassidykelly/events{/privacy}", "received_events_url": "https://api.github.com/users/cassidykelly/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nice, thanks for the fix." ]
2016-12-12T00:16:57
2016-12-12T22:12:18
2016-12-12T22:12:14
CONTRIBUTOR
null
I was able to run cross join queries after making this change.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1145/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1145/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1145", "html_url": "https://github.com/coleifer/peewee/pull/1145", "diff_url": "https://github.com/coleifer/peewee/pull/1145.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1145.patch", "merged_at": "2016-12-12T22:12:14" }
https://api.github.com/repos/coleifer/peewee/issues/1144
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1144/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1144/comments
https://api.github.com/repos/coleifer/peewee/issues/1144/events
https://github.com/coleifer/peewee/issues/1144
194,304,023
MDU6SXNzdWUxOTQzMDQwMjM=
1,144
Misunderstanding somethng or weird behaviour ?
{ "login": "stuaxo", "id": 179677, "node_id": "MDQ6VXNlcjE3OTY3Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/179677?v=4", "gravatar_id": "", "url": "https://api.github.com/users/stuaxo", "html_url": "https://github.com/stuaxo", "followers_url": "https://api.github.com/users/stuaxo/followers", "following_url": "https://api.github.com/users/stuaxo/following{/other_user}", "gists_url": "https://api.github.com/users/stuaxo/gists{/gist_id}", "starred_url": "https://api.github.com/users/stuaxo/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/stuaxo/subscriptions", "organizations_url": "https://api.github.com/users/stuaxo/orgs", "repos_url": "https://api.github.com/users/stuaxo/repos", "events_url": "https://api.github.com/users/stuaxo/events{/privacy}", "received_events_url": "https://api.github.com/users/stuaxo/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Worse - if I use\r\n\r\n```\r\nr.filename = filename\r\nr.save()\r\n```\r\nData in other tables seem to get saved, with default values overwriting the proper values.\r\n\r\n(I switched from save() because of this initial problem)... now I've tested going back, it has this other bug.", "Hi,\r\n I'm going to close this. - Project I'm on is on a silly deadline, so don't have time to simply reproduce it unfortunately. Our app is has quite a few threads using asyncio, which may be the issue. .. It'll take about the same time to move our app to SqlAlchemy as it would to make a simple example, so were going on this path.\r\n\r\nCheers\r\nS", "You need to call \".execute()\" to actually execute the update query.", "Sorry I didn't see this sooner, but hopefully this information finds you in time to make your project work.", "Cheers for the info :)" ]
2016-12-08T10:49:18
2016-12-12T11:10:37
2016-12-09T17:50:05
NONE
null
I've got a connection to a sqlite db and a table like this one : ``` class Resource(Model): # [snipped other fields] filename = CharField(null=True) ``` If I do ``` resources = models.Resource.select().where(models.Resource.filename == None) for r in resources: r.update(filename=filename) import ipdb; ipdb.set_trace() ``` Then r.filename is None... ``` >>> r.filename == None True ``` Is this expected? How can I set this value ?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1144/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1144/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1143
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1143/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1143/comments
https://api.github.com/repos/coleifer/peewee/issues/1143/events
https://github.com/coleifer/peewee/issues/1143
194,251,196
MDU6SXNzdWUxOTQyNTExOTY=
1,143
About connection pool
{ "login": "521xueweihan", "id": 8255800, "node_id": "MDQ6VXNlcjgyNTU4MDA=", "avatar_url": "https://avatars.githubusercontent.com/u/8255800?v=4", "gravatar_id": "", "url": "https://api.github.com/users/521xueweihan", "html_url": "https://github.com/521xueweihan", "followers_url": "https://api.github.com/users/521xueweihan/followers", "following_url": "https://api.github.com/users/521xueweihan/following{/other_user}", "gists_url": "https://api.github.com/users/521xueweihan/gists{/gist_id}", "starred_url": "https://api.github.com/users/521xueweihan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/521xueweihan/subscriptions", "organizations_url": "https://api.github.com/users/521xueweihan/orgs", "repos_url": "https://api.github.com/users/521xueweihan/repos", "events_url": "https://api.github.com/users/521xueweihan/events{/privacy}", "received_events_url": "https://api.github.com/users/521xueweihan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Connections must be closed by the application writer. It is a good practice to ensure that your connections are opened and closed in a sensible way." ]
2016-12-08T05:35:09
2016-12-11T21:19:23
2016-12-11T21:19:23
NONE
null
Hi coleifer, First peewee is awesome, It is very useful. Thank you. There I consult for something about `connection pool`. when I use the peewee connection pool, I meet some problem: `Exceeded maximum connections.` and `Error 2006: “MySQL server has gone away”`, so I read document and peewee source code solve this two Error. The reason is: I don't close the connection when I use the pool. So I try to find a way to fix it out. The document give two way to auto close connection: ```python with db.execution_context(): # A new connection will be opened or, if using a connection pool, # pulled from the pool of available connections. Additionally, a # transaction will be started. for user in get_all_user(): user_id = user['id'] rule = Rule(user_id) rule_dict = rule.slack_rule() .....do something..... ``` ```python @app.before_request def _db_connect(): database.connect() # # This hook ensures that the connection is closed when we've finished # processing the request. @app.teardown_request def _db_close(exc): if not database.is_closed(): database.close() # # # from playhouse.flask_utils import FlaskDB from dock_fastgear.model.base import db # app = Flask(__name__) FlaskDB(app, db) ``` At last , I have a question: Why connection alway close by myself(Implicit or Dominant), Because can't check `_in_use` connections timeout ? There is no automatic management of connections, The feature will be there?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1143/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1143/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1142
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1142/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1142/comments
https://api.github.com/repos/coleifer/peewee/issues/1142/events
https://github.com/coleifer/peewee/issues/1142
194,148,725
MDU6SXNzdWUxOTQxNDg3MjU=
1,142
Handle change from default null to not null
{ "login": "c0ldcalamari", "id": 11208820, "node_id": "MDQ6VXNlcjExMjA4ODIw", "avatar_url": "https://avatars.githubusercontent.com/u/11208820?v=4", "gravatar_id": "", "url": "https://api.github.com/users/c0ldcalamari", "html_url": "https://github.com/c0ldcalamari", "followers_url": "https://api.github.com/users/c0ldcalamari/followers", "following_url": "https://api.github.com/users/c0ldcalamari/following{/other_user}", "gists_url": "https://api.github.com/users/c0ldcalamari/gists{/gist_id}", "starred_url": "https://api.github.com/users/c0ldcalamari/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/c0ldcalamari/subscriptions", "organizations_url": "https://api.github.com/users/c0ldcalamari/orgs", "repos_url": "https://api.github.com/users/c0ldcalamari/repos", "events_url": "https://api.github.com/users/c0ldcalamari/events{/privacy}", "received_events_url": "https://api.github.com/users/c0ldcalamari/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-12-07T19:44:00
2016-12-07T19:44:45
2016-12-07T19:44:45
NONE
null
Handle change from default null to not null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1142/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1142/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1141
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1141/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1141/comments
https://api.github.com/repos/coleifer/peewee/issues/1141/events
https://github.com/coleifer/peewee/issues/1141
193,399,836
MDU6SXNzdWUxOTMzOTk4MzY=
1,141
No PasswordField in playhouse.fields
{ "login": "Morriaty-The-Murderer", "id": 12904434, "node_id": "MDQ6VXNlcjEyOTA0NDM0", "avatar_url": "https://avatars.githubusercontent.com/u/12904434?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Morriaty-The-Murderer", "html_url": "https://github.com/Morriaty-The-Murderer", "followers_url": "https://api.github.com/users/Morriaty-The-Murderer/followers", "following_url": "https://api.github.com/users/Morriaty-The-Murderer/following{/other_user}", "gists_url": "https://api.github.com/users/Morriaty-The-Murderer/gists{/gist_id}", "starred_url": "https://api.github.com/users/Morriaty-The-Murderer/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Morriaty-The-Murderer/subscriptions", "organizations_url": "https://api.github.com/users/Morriaty-The-Murderer/orgs", "repos_url": "https://api.github.com/users/Morriaty-The-Murderer/repos", "events_url": "https://api.github.com/users/Morriaty-The-Murderer/events{/privacy}", "received_events_url": "https://api.github.com/users/Morriaty-The-Murderer/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Sorry for ignoring this tip\r\n>Note\r\n>This field requires bcrypt, which can be installed by running pip install bcrypt." ]
2016-12-05T02:49:42
2016-12-05T02:58:54
2016-12-05T02:58:54
NONE
null
Hi I got an error when trying to import PasswordField. Then I checked this ```python >>> from playhouse import fields >>> fields.P fields.PY2 fields.PickledField( fields.PrimaryKeyField( fields.Proxy( fields.Param( fields.PostgresqlDatabase( fields.ProgrammingError( >>> import peewee >>> peewee.__version__ peewee.__version__ >>> peewee.__version__ '2.8.5' ``` The only reason I supposed was that the os kernel was too old ```bash $ uname -a Linux prod-bj-sem-20-143 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux ``` So should I install some extra libraries?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1141/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1141/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1140
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1140/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1140/comments
https://api.github.com/repos/coleifer/peewee/issues/1140/events
https://github.com/coleifer/peewee/issues/1140
193,348,989
MDU6SXNzdWUxOTMzNDg5ODk=
1,140
Model.get_or_none
{ "login": "razodactyl", "id": 1160532, "node_id": "MDQ6VXNlcjExNjA1MzI=", "avatar_url": "https://avatars.githubusercontent.com/u/1160532?v=4", "gravatar_id": "", "url": "https://api.github.com/users/razodactyl", "html_url": "https://github.com/razodactyl", "followers_url": "https://api.github.com/users/razodactyl/followers", "following_url": "https://api.github.com/users/razodactyl/following{/other_user}", "gists_url": "https://api.github.com/users/razodactyl/gists{/gist_id}", "starred_url": "https://api.github.com/users/razodactyl/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/razodactyl/subscriptions", "organizations_url": "https://api.github.com/users/razodactyl/orgs", "repos_url": "https://api.github.com/users/razodactyl/repos", "events_url": "https://api.github.com/users/razodactyl/events{/privacy}", "received_events_url": "https://api.github.com/users/razodactyl/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm currently using this on my 'BaseModel' implementation which is a subclass of 'db.Model' which came from the FlaskDB helper.\r\n\r\n```\r\nclass BaseModel(db.Model):\r\n @classmethod\r\n def get_or_none(cls, *query, **kwargs):\r\n try:\r\n return cls.get(*query)\r\n except cls.DoesNotExist:\r\n return None\r\n```", " user = User.select().where(username == 'not-created').first()\r\n\r\nThat's what I usually do. `first()` will return a record or None.", "Thanks @timster " ]
2016-12-04T12:46:09
2016-12-11T21:17:30
2016-12-11T21:17:30
NONE
null
I think the only place I found this behaviour was in the Dataset utility. Usually, to get a row you would use Model.get. However, if the row doesn't exist, a DoesNotExist is thrown. I propose a 'get_or_none' function to return None instead of throwing an error, in this way, you can simply query a record and have nothing if there's no records. e.g ``` user = User.get(username == 'razodactyl') # returns User user = User.get(username == 'not_created_yet') # returns None ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1140/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1140/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1139
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1139/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1139/comments
https://api.github.com/repos/coleifer/peewee/issues/1139/events
https://github.com/coleifer/peewee/pull/1139
193,293,341
MDExOlB1bGxSZXF1ZXN0OTY0MDA2NDI=
1,139
Fixed renaming unique foreign key in MySQL
{ "login": "dext0r", "id": 3103856, "node_id": "MDQ6VXNlcjMxMDM4NTY=", "avatar_url": "https://avatars.githubusercontent.com/u/3103856?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dext0r", "html_url": "https://github.com/dext0r", "followers_url": "https://api.github.com/users/dext0r/followers", "following_url": "https://api.github.com/users/dext0r/following{/other_user}", "gists_url": "https://api.github.com/users/dext0r/gists{/gist_id}", "starred_url": "https://api.github.com/users/dext0r/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dext0r/subscriptions", "organizations_url": "https://api.github.com/users/dext0r/orgs", "repos_url": "https://api.github.com/users/dext0r/repos", "events_url": "https://api.github.com/users/dext0r/events{/privacy}", "received_events_url": "https://api.github.com/users/dext0r/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "gametight, thanks!" ]
2016-12-03T15:25:00
2016-12-11T21:28:10
2016-12-11T21:28:10
CONTRIBUTOR
null
When i trying to rename unique foreign key in MySQL, i got error: `peewee.OperationalError: (1091, "Can't DROP '...'; check that column/key exists")` Here is a demo code: ```python # coding: utf8 import logging from peewee import MySQLDatabase, Model, ForeignKeyField, IntegerField from playhouse.migrate import MySQLMigrator, migrate db = MySQLDatabase(host='prl-s.shared', user='root', database='test') logger = logging.getLogger('peewee') logger.setLevel(logging.DEBUG) logger.addHandler(logging.StreamHandler()) class ModelA(Model): class Meta: database = db class ModelB(Model): a = ForeignKeyField(ModelA, unique=True) class Meta: database = db db.connect() db.execute_sql('drop table if exists modelb, modela') ModelA.create_table() ModelB.create_table() migrator = MySQLMigrator(db) migrate( migrator.rename_column('modelb', 'a_id', 'a_id_renamed') ) ``` Output: ``` ('drop table if exists modelb, modela', None) ('CREATE TABLE `modela` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY)', []) ('CREATE TABLE `modelb` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `a_id` INTEGER NOT NULL, `foo` INTEGER, FOREIGN KEY (`a_id`) REFERENCES `modela` (`id`))', []) ('CREATE UNIQUE INDEX `modelb_a_id` ON `modelb` (`a_id`)', []) ('\n SELECT column_name, referenced_table_name, referenced_column_name\n FROM information_schema.key_column_usage\n WHERE table_name = %s\n AND table_schema = DATABASE()\n AND referenced_table_name IS NOT NULL\n AND referenced_column_name IS NOT NULL', ('modelb',)) ('DESCRIBE modelb;', None) ('SELECT constraint_name FROM information_schema.key_column_usage WHERE table_schema = DATABASE() AND table_name = %s AND column_name = %s;', ('modelb', 'a_id')) (u'ALTER TABLE `modelb` DROP FOREIGN KEY `modelb_a_id`', []) Traceback (most recent call last): File '_.py", line 33, in <module> migrator.rename_column('modelb', 'a_id', 'a_id_renamed') File "/peewee/playhouse/migrate.py", line 711, in migrate operation.run() File "/peewee/playhouse/migrate.py", line 144, in run getattr(self.migrator, self.method)(*self.args, **kwargs)) File "/peewee/playhouse/migrate.py", line 138, in _handle_result self._handle_result(item) File "/peewee/playhouse/migrate.py", line 135, in _handle_result result.run() File "/peewee/playhouse/migrate.py", line 144, in run getattr(self.migrator, self.method)(*self.args, **kwargs)) File "/peewee/playhouse/migrate.py", line 133, in _handle_result self.execute(result) File "/peewee/playhouse/migrate.py", line 129, in execute self.migrator.database.execute_sql(sql, params) File "/peewee/peewee.py", line 3714, in execute_sql self.commit() File "/peewee/peewee.py", line 3537, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "/peewee/peewee.py", line 3707, in execute_sql cursor.execute(sql, params or ()) File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute self.errorhandler(self, exc, value) File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue peewee.OperationalError: (1091, "Can't DROP 'modelb_a_id'; check that column/key exists") ``` This pull request fixes that. Though I'm not sure if i wrote a test case correctly.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1139/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1139/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1139", "html_url": "https://github.com/coleifer/peewee/pull/1139", "diff_url": "https://github.com/coleifer/peewee/pull/1139.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1139.patch", "merged_at": "2016-12-11T21:28:10" }
https://api.github.com/repos/coleifer/peewee/issues/1138
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1138/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1138/comments
https://api.github.com/repos/coleifer/peewee/issues/1138/events
https://github.com/coleifer/peewee/issues/1138
193,201,609
MDU6SXNzdWUxOTMyMDE2MDk=
1,138
peewee connection pooling returns broken connections from the pool
{ "login": "c0ldcalamari", "id": 11208820, "node_id": "MDQ6VXNlcjExMjA4ODIw", "avatar_url": "https://avatars.githubusercontent.com/u/11208820?v=4", "gravatar_id": "", "url": "https://api.github.com/users/c0ldcalamari", "html_url": "https://github.com/c0ldcalamari", "followers_url": "https://api.github.com/users/c0ldcalamari/followers", "following_url": "https://api.github.com/users/c0ldcalamari/following{/other_user}", "gists_url": "https://api.github.com/users/c0ldcalamari/gists{/gist_id}", "starred_url": "https://api.github.com/users/c0ldcalamari/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/c0ldcalamari/subscriptions", "organizations_url": "https://api.github.com/users/c0ldcalamari/orgs", "repos_url": "https://api.github.com/users/c0ldcalamari/repos", "events_url": "https://api.github.com/users/c0ldcalamari/events{/privacy}", "received_events_url": "https://api.github.com/users/c0ldcalamari/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Merged 082f13bf6b3a740c07bf35dafaf699e236b097e1" ]
2016-12-02T19:46:06
2017-01-30T22:12:20
2017-01-30T22:12:20
NONE
null
If you execute some bad SQL like `select * from not_a_table;` postgres will leave you in a [CONNECTION_BAD](https://www.postgresql.org/docs/9.1/static/libpq-status.html) state. Requiring you to rollback or reset the connection before continuing. Peewee intentionally leaves this up to the user to handle (either through the [`autorollback`](https://github.com/coleifer/peewee/issues/240) param or otherwise). If the user doesn't handle it, all future SQL statements will fail. This is fine, but if the user *doesn't* handle it, the connection should not be put back into the pool as-is. Connection pools should return functionally new connections each time. The next user of the pool should not have to worry about what the previous user did or did not do. Example of the pool returning a borked connection: ```python import playhouse.db_url DB_URL = 'postgresext+pool:///template1' db = playhouse.db_url.connect(DB_URL) db.connect() try: db.execute_sql('select * from not_a_table;') except Exception as e: print 'got', repr(e.message), 'but ignoring' # close the bad connection, returning it to the pool db.close() # get a "new" connection from the pool db.connect() # this should not fail, but does db.execute_sql('select 1;') db.close() ``` `psycopg2` knows in-memory (not requiring a network call) the state of the connection, so it should be easy to detect without a performance hit, and offers a `reset()` method that fixes it, so this should be an easy fix.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1138/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1138/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1137
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1137/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1137/comments
https://api.github.com/repos/coleifer/peewee/issues/1137/events
https://github.com/coleifer/peewee/pull/1137
193,201,207
MDExOlB1bGxSZXF1ZXN0OTYzNDA1ODc=
1,137
fix bad pg connections before returning to pool
{ "login": "c0ldcalamari", "id": 11208820, "node_id": "MDQ6VXNlcjExMjA4ODIw", "avatar_url": "https://avatars.githubusercontent.com/u/11208820?v=4", "gravatar_id": "", "url": "https://api.github.com/users/c0ldcalamari", "html_url": "https://github.com/c0ldcalamari", "followers_url": "https://api.github.com/users/c0ldcalamari/followers", "following_url": "https://api.github.com/users/c0ldcalamari/following{/other_user}", "gists_url": "https://api.github.com/users/c0ldcalamari/gists{/gist_id}", "starred_url": "https://api.github.com/users/c0ldcalamari/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/c0ldcalamari/subscriptions", "organizations_url": "https://api.github.com/users/c0ldcalamari/orgs", "repos_url": "https://api.github.com/users/c0ldcalamari/repos", "events_url": "https://api.github.com/users/c0ldcalamari/events{/privacy}", "received_events_url": "https://api.github.com/users/c0ldcalamari/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This is fantastic, thank you. I will merge, but I'd like to tighten up the API first. Thanks again.", "I've made some small cleanups/changes to the APIs but this feature is now merged. Thanks again.\r\n\r\n082f13bf6b3a740c07bf35dafaf699e236b097e1" ]
2016-12-02T19:44:20
2017-01-30T22:11:58
2017-01-30T22:11:58
NONE
null
For https://github.com/coleifer/peewee/issues/1138 Thanks!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1137/reactions", "total_count": 1, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 1, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1137/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1137", "html_url": "https://github.com/coleifer/peewee/pull/1137", "diff_url": "https://github.com/coleifer/peewee/pull/1137.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1137.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1136
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1136/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1136/comments
https://api.github.com/repos/coleifer/peewee/issues/1136/events
https://github.com/coleifer/peewee/issues/1136
193,170,342
MDU6SXNzdWUxOTMxNzAzNDI=
1,136
Remove `*` imports in doc
{ "login": "maxnoe", "id": 5488440, "node_id": "MDQ6VXNlcjU0ODg0NDA=", "avatar_url": "https://avatars.githubusercontent.com/u/5488440?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maxnoe", "html_url": "https://github.com/maxnoe", "followers_url": "https://api.github.com/users/maxnoe/followers", "following_url": "https://api.github.com/users/maxnoe/following{/other_user}", "gists_url": "https://api.github.com/users/maxnoe/gists{/gist_id}", "starred_url": "https://api.github.com/users/maxnoe/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maxnoe/subscriptions", "organizations_url": "https://api.github.com/users/maxnoe/orgs", "repos_url": "https://api.github.com/users/maxnoe/repos", "events_url": "https://api.github.com/users/maxnoe/events{/privacy}", "received_events_url": "https://api.github.com/users/maxnoe/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yeah, I hear that. I guess, as the author, I'm always aware of that stuff but I can see how it would be super confusing in the docs. I'll update them as I find the time.", "Well, I looked into this a bit. The `import *` are actually necessary in some places because extension modules typically will shadow peewee globals. Peewee has always been made with an eye towards `from peewee import *` so ...think I'm going to just leave this one alone." ]
2016-12-02T17:17:30
2016-12-30T21:54:56
2016-12-30T21:54:56
NONE
null
The one thing that often tends to annoy me when reading the docs is the use of `from peewee import *` or `from playhouse.migrate import *`. One never really knows where stuff comes from.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1136/reactions", "total_count": 3, "+1": 3, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1136/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1135
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1135/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1135/comments
https://api.github.com/repos/coleifer/peewee/issues/1135/events
https://github.com/coleifer/peewee/issues/1135
192,666,006
MDU6SXNzdWUxOTI2NjYwMDY=
1,135
Possibility to exclude certain columns from default selection
{ "login": "maxnoe", "id": 5488440, "node_id": "MDQ6VXNlcjU0ODg0NDA=", "avatar_url": "https://avatars.githubusercontent.com/u/5488440?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maxnoe", "html_url": "https://github.com/maxnoe", "followers_url": "https://api.github.com/users/maxnoe/followers", "following_url": "https://api.github.com/users/maxnoe/following{/other_user}", "gists_url": "https://api.github.com/users/maxnoe/gists{/gist_id}", "starred_url": "https://api.github.com/users/maxnoe/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maxnoe/subscriptions", "organizations_url": "https://api.github.com/users/maxnoe/orgs", "repos_url": "https://api.github.com/users/maxnoe/repos", "events_url": "https://api.github.com/users/maxnoe/events{/privacy}", "received_events_url": "https://api.github.com/users/maxnoe/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Just write a custom method." ]
2016-11-30T20:08:54
2016-12-11T21:24:47
2016-12-11T21:24:47
NONE
null
The default for `peewees` `select()` is to request all columns. Could it be possible to exclude columns from this selection? E.g. something like: ```python class MyModel(Model): x = FloatField() data = BlobField() class Meta: database = database exclude_from_default_select = [data] ``` I ran into some performance issues, because I somewhere always requested a large blob through a foreign key traversion. Now I do something like ```python b = ModelB.select(ModelB.some_field).where(ModelB.id == a.model_b_id).get() some_field = b.some_field ``` Instead of just accessing ``` a.model_b.some_field ``` because `ModelB` has a large Binary blob. It would really simplify my code if I could exclude the blob field from the foreign key traversion. Thanks for the great package and for any help!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1135/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1135/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1134
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1134/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1134/comments
https://api.github.com/repos/coleifer/peewee/issues/1134/events
https://github.com/coleifer/peewee/pull/1134
190,485,525
MDExOlB1bGxSZXF1ZXN0OTQ0NzU4ODI=
1,134
Fixed db_field for DateTimeTz in postgres_ext
{ "login": "kammala", "id": 4599701, "node_id": "MDQ6VXNlcjQ1OTk3MDE=", "avatar_url": "https://avatars.githubusercontent.com/u/4599701?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kammala", "html_url": "https://github.com/kammala", "followers_url": "https://api.github.com/users/kammala/followers", "following_url": "https://api.github.com/users/kammala/following{/other_user}", "gists_url": "https://api.github.com/users/kammala/gists{/gist_id}", "starred_url": "https://api.github.com/users/kammala/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kammala/subscriptions", "organizations_url": "https://api.github.com/users/kammala/orgs", "repos_url": "https://api.github.com/users/kammala/repos", "events_url": "https://api.github.com/users/kammala/events{/privacy}", "received_events_url": "https://api.github.com/users/kammala/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-11-19T08:55:04
2016-11-19T17:01:00
2016-11-19T17:01:00
CONTRIBUTOR
null
cause since 9.6 `datetime_tz` is not supported.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1134/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1134/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1134", "html_url": "https://github.com/coleifer/peewee/pull/1134", "diff_url": "https://github.com/coleifer/peewee/pull/1134.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1134.patch", "merged_at": "2016-11-19T17:01:00" }
https://api.github.com/repos/coleifer/peewee/issues/1133
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1133/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1133/comments
https://api.github.com/repos/coleifer/peewee/issues/1133/events
https://github.com/coleifer/peewee/issues/1133
190,249,810
MDU6SXNzdWUxOTAyNDk4MTA=
1,133
DecimalField field does not attempt to coerce/convert values
{ "login": "talawahtech", "id": 2263809, "node_id": "MDQ6VXNlcjIyNjM4MDk=", "avatar_url": "https://avatars.githubusercontent.com/u/2263809?v=4", "gravatar_id": "", "url": "https://api.github.com/users/talawahtech", "html_url": "https://github.com/talawahtech", "followers_url": "https://api.github.com/users/talawahtech/followers", "following_url": "https://api.github.com/users/talawahtech/following{/other_user}", "gists_url": "https://api.github.com/users/talawahtech/gists{/gist_id}", "starred_url": "https://api.github.com/users/talawahtech/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/talawahtech/subscriptions", "organizations_url": "https://api.github.com/users/talawahtech/orgs", "repos_url": "https://api.github.com/users/talawahtech/repos", "events_url": "https://api.github.com/users/talawahtech/events{/privacy}", "received_events_url": "https://api.github.com/users/talawahtech/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "If `auto_round` is set to `True` then peewee will call `str()` on the value before passing it into the `Decimal` constructor. Otherwise, peewee passes the value back to the database as-is.\n\nOn the other side, when loading values from the db into python, Peewee will convert the value to a string then pass it in to the Decimal constructor (if the value is not already a Decimal object).\n\nCan you provide the specific example you're having trouble with?\n", "Yes, I see that the conversion happens when auto_round is set, but I was expecting it to also happen without auto_round. For example, given the following string input: \"1\" IntegerField, FloatField, etc will all coerce the value to their corresponding numeric representations, while DecimalField will send the string along to the DB/driver as is.\n\nOn the flip side, given the string input \"garbage223\", using IntegerField will throw an Exception while a DecimalField will send the value to the DB. I discovered this issue when I realized that bad data in a DecimalField was silently converted to 0.0000 by MySQL and a pymysql warning was printed to the log instead. It seems much more consistent to attempt the conversion in peewee just like with the other numeric fields so that users can handle all exceptions in the same way.\n\nBasically instead of simply returning value, I would expect you to return decimal.Decimal(str(value))\n", "Actually, let me add that you should probably also check is_infinite() and is_nan() on the converted decimal values before returning or calling quantize(). Otherwise the strings \"inf\" and \"nan\" could cause trouble as well \n", "> when I realized that bad data in a DecimalField was silently converted to 0.0000 by MySQL\r\n\r\nShit! That's certainly surprising. I think it's ok to blame the problem on MySQL rather than Peewee...or pymysql...something should have broken higher up the call-stack.\r\n\r\nThat being said, I think it makes sense to add logic to convert to Decimal object in Peewee's db_value() method, so I've gone ahead and done that. Also skip quantization when the value is something like NaN/Inf, etc." ]
2016-11-18T06:59:46
2016-11-22T10:40:08
2016-11-22T10:40:08
NONE
null
I have noticed that unlike most other numeric fields, DecimalField does not attempt to coerce/convert values (e.g. strings) before inserting them into the database. Is there a specific reason for this or is it just an oversight. Seems like it would to be consistent with the behavior of IntegerField and FloatField
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1133/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1133/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1132
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1132/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1132/comments
https://api.github.com/repos/coleifer/peewee/issues/1132/events
https://github.com/coleifer/peewee/issues/1132
190,248,099
MDU6SXNzdWUxOTAyNDgwOTk=
1,132
Max recursion depth exceeded - JSON Type query w/ Postgresql
{ "login": "wmturner", "id": 10918018, "node_id": "MDQ6VXNlcjEwOTE4MDE4", "avatar_url": "https://avatars.githubusercontent.com/u/10918018?v=4", "gravatar_id": "", "url": "https://api.github.com/users/wmturner", "html_url": "https://github.com/wmturner", "followers_url": "https://api.github.com/users/wmturner/followers", "following_url": "https://api.github.com/users/wmturner/following{/other_user}", "gists_url": "https://api.github.com/users/wmturner/gists{/gist_id}", "starred_url": "https://api.github.com/users/wmturner/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/wmturner/subscriptions", "organizations_url": "https://api.github.com/users/wmturner/orgs", "repos_url": "https://api.github.com/users/wmturner/repos", "events_url": "https://api.github.com/users/wmturner/events{/privacy}", "received_events_url": "https://api.github.com/users/wmturner/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The problem appears to be that you're using `PostgresqlDatabase` as opposed to `PostgresqlExtDatabase`. The former does not know how to parse JSON things into SQL, while the latter does. I admit the error message could be more helpful, but that's the issue. If you switch your DB initialization you'll be set.\n", "Sweet, thanks for the help." ]
2016-11-18T06:46:25
2016-11-22T03:51:05
2016-11-18T19:02:04
NONE
null
Hello, I'm just getting started with peewee and am using Postgresql with a few JSON type columns. When trying to query on one of the elements in the JSON document I get a maximum recursion level exceeded error. The code I have so far is here: https://gist.github.com/wmturner/7288bbf715d81df916cb6b561057e490 And the error looks like: File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1823, in parse_node csql, cparams = self.parse_node(param) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1823, in parse_node csql, cparams = self.parse_node(param) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1823, in parse_node csql, cparams = self.parse_node(param) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1823, in parse_node csql, cparams = self.parse_node(param) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1806, in parse_node sql, params, unknown = self._parse(node, alias_map, conv) File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1792, in _parse elif (isclass(node) and issubclass(node, Model)) or \ File "/usr/lib/python2.7/inspect.py", line 65, in isclass return isinstance(object, (type, types.ClassType)) RuntimeError: maximum recursion depth exceeded while calling a Python object I'm probably just doing it wrong or not seeing a glaring error, so any help would be greatly appreciated! Best, -William
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1132/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1132/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1131
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1131/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1131/comments
https://api.github.com/repos/coleifer/peewee/issues/1131/events
https://github.com/coleifer/peewee/issues/1131
189,704,659
MDU6SXNzdWUxODk3MDQ2NTk=
1,131
Math operators in query
{ "login": "ak4nv", "id": 73960, "node_id": "MDQ6VXNlcjczOTYw", "avatar_url": "https://avatars.githubusercontent.com/u/73960?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ak4nv", "html_url": "https://github.com/ak4nv", "followers_url": "https://api.github.com/users/ak4nv/followers", "following_url": "https://api.github.com/users/ak4nv/following{/other_user}", "gists_url": "https://api.github.com/users/ak4nv/gists{/gist_id}", "starred_url": "https://api.github.com/users/ak4nv/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ak4nv/subscriptions", "organizations_url": "https://api.github.com/users/ak4nv/orgs", "repos_url": "https://api.github.com/users/ak4nv/repos", "events_url": "https://api.github.com/users/ak4nv/events{/privacy}", "received_events_url": "https://api.github.com/users/ak4nv/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What errors do you receive? \nWhat SQL is composed?\n", "Well, `fn.current_date` should be written as: `fn.current_date()`, unless that's some magical name in which case you should just write `SQL('current_date')`.\n\nMath operators work as you'd expect, so theoretically your query would work provided your database understands the expression \"current_date - cast(table.ts as date)\".\n\nTry fixing the function call as I described. It looks like you need to use the \"SQL('current_date')\" construction as opposed to the function call.\n", "@coleifer great man!!! That's I wanted!\n" ]
2016-11-16T13:32:19
2016-11-18T00:44:53
2016-11-17T17:54:46
NONE
null
Hi! I have a `peewee.DateTimeField`in my model. And I need calculate duration between date in this field and current date in days. ```python from peewee import DatetTimeField, fn from playhouse.shortcuts import cast from config import db from datetime import datetime class Table(db.Model): ts = DateTimeField(default=datetime.now) duration = fn.current_date - cast(Table.ts, 'date') qs = Table.select(duration.alias('duration')).dicts() ``` But it not works. Where I have mistaken? SQL query works fine: ```sql select current_date - cast(ts as 'date') as duration from table ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1131/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1131/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1130
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1130/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1130/comments
https://api.github.com/repos/coleifer/peewee/issues/1130/events
https://github.com/coleifer/peewee/issues/1130
188,955,614
MDU6SXNzdWUxODg5NTU2MTQ=
1,130
Not able to query in ForeignKeyField
{ "login": "rahul3103", "id": 10813252, "node_id": "MDQ6VXNlcjEwODEzMjUy", "avatar_url": "https://avatars.githubusercontent.com/u/10813252?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rahul3103", "html_url": "https://github.com/rahul3103", "followers_url": "https://api.github.com/users/rahul3103/followers", "following_url": "https://api.github.com/users/rahul3103/following{/other_user}", "gists_url": "https://api.github.com/users/rahul3103/gists{/gist_id}", "starred_url": "https://api.github.com/users/rahul3103/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rahul3103/subscriptions", "organizations_url": "https://api.github.com/users/rahul3103/orgs", "repos_url": "https://api.github.com/users/rahul3103/repos", "events_url": "https://api.github.com/users/rahul3103/events{/privacy}", "received_events_url": "https://api.github.com/users/rahul3103/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You're close, you would write it as:\n\n``` python\nMenuItem.select().join(Restaurant).where(Restaurant.name == name)\n\nMenuItem.select().where(MenuItem.restaurant == restaurant_id)\n```\n", "Thanks\n" ]
2016-11-13T06:40:22
2016-11-14T05:12:16
2016-11-13T21:58:27
NONE
null
My `model.py` ```python from peewee import Model, CharField from playhouse.sqlite_ext import ForeignKeyField from playhouse.pool import SqliteExtDatabase import settings db = SqliteExtDatabase(settings.DB_NAME) class BaseModel(Model): """A base model that will use our Sqlite database""" class Meta: database = db class Restaurant(BaseModel): """ORM model of the Restaurant table""" name = CharField(null=False) class MenuItem(BaseModel): """ORM model of the MenuItem table""" name = CharField(null=False) course = CharField() description = CharField() price = CharField() restaurant = ForeignKeyField(Restaurant, null=False, db_column='restaurant_id') ``` When I am trying to query like this I am getting following error: ``` In [5]: menu = MenuItem.select().where(MenuItem.restaurant.id == 2).first() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-5-4a02ff7da8b8> in <module>() ----> 1 menu = MenuItem.select().where(MenuItem.restaurant.id == 2).first() AttributeError: 'ForeignKeyField' object has no attribute 'id' ``` But I am able to query like this: ``` In [7]: menu = MenuItem.select().first() In [8]: menu.restaurant.id Out[8]: 1 In [9]: menu.restaurant.name Out[9]: u'Pizza Palace' ``` Same problem I am getting while: ``` menu = MenuItem.select().where(MenuItem.restaurant.name == 'Veggie Burger').first() ``` Here I am not getting error but I am getting zero output from the query even though I have rows for that query in db.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1130/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1130/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1129
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1129/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1129/comments
https://api.github.com/repos/coleifer/peewee/issues/1129/events
https://github.com/coleifer/peewee/issues/1129
188,796,879
MDU6SXNzdWUxODg3OTY4Nzk=
1,129
Extending PooledDatabase to optionally wait before throwing the "Exceeded maximum connections" exception
{ "login": "decoratorz", "id": 8288881, "node_id": "MDQ6VXNlcjgyODg4ODE=", "avatar_url": "https://avatars.githubusercontent.com/u/8288881?v=4", "gravatar_id": "", "url": "https://api.github.com/users/decoratorz", "html_url": "https://github.com/decoratorz", "followers_url": "https://api.github.com/users/decoratorz/followers", "following_url": "https://api.github.com/users/decoratorz/following{/other_user}", "gists_url": "https://api.github.com/users/decoratorz/gists{/gist_id}", "starred_url": "https://api.github.com/users/decoratorz/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/decoratorz/subscriptions", "organizations_url": "https://api.github.com/users/decoratorz/orgs", "repos_url": "https://api.github.com/users/decoratorz/repos", "events_url": "https://api.github.com/users/decoratorz/events{/privacy}", "received_events_url": "https://api.github.com/users/decoratorz/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Well, theoretically you could implement this yourself by putting some kind of polling around the connect method. I think it'd require some re-architecting to get this working more generally. I'll think about it.\n", "I've added this feature. You can now specify a `timeout` when instantiating a subclass of `PooledDatabase`. To block forever simply set the timeout to zero." ]
2016-11-11T16:25:57
2016-12-30T22:23:53
2016-12-30T22:23:18
NONE
null
We need to extend the Peewee's pool implementation with the timeout option which would allow to wait some time for connection when a pool is full instead of always throwing an exception immediately. The aim is to do it "the right way" and have this change merged upstream. Problem is, it's hard to do locally in playhouse/pool because all calls to `_connect/_close` are protected with the `self._conn_lock` in the parent Database class and in ExecutionContext from the main module, so we can't wait inside `_connect` without manually releasing this upper level lock which doesn't look like a good solution. Because this seemingly local feature could require refactoring in the main module we'd like to ask for your feedback first on how you see it implemented properly, or even see it in Peewee at all. Thanks.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1129/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1129/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1128
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1128/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1128/comments
https://api.github.com/repos/coleifer/peewee/issues/1128/events
https://github.com/coleifer/peewee/issues/1128
188,696,832
MDU6SXNzdWUxODg2OTY4MzI=
1,128
How can I omit creation of a field but still have it in my model?
{ "login": "maaaks", "id": 3010238, "node_id": "MDQ6VXNlcjMwMTAyMzg=", "avatar_url": "https://avatars.githubusercontent.com/u/3010238?v=4", "gravatar_id": "", "url": "https://api.github.com/users/maaaks", "html_url": "https://github.com/maaaks", "followers_url": "https://api.github.com/users/maaaks/followers", "following_url": "https://api.github.com/users/maaaks/following{/other_user}", "gists_url": "https://api.github.com/users/maaaks/gists{/gist_id}", "starred_url": "https://api.github.com/users/maaaks/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/maaaks/subscriptions", "organizations_url": "https://api.github.com/users/maaaks/orgs", "repos_url": "https://api.github.com/users/maaaks/repos", "events_url": "https://api.github.com/users/maaaks/events{/privacy}", "received_events_url": "https://api.github.com/users/maaaks/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Maybe there is an easier way to do what I want, by somehow cheating in `MyModel.create()`, but I don't understand how.\n", "Just added \"undeclared\" option, which was useful to me for a similar thing in SQLite regarding the \"rowid\" field. Commit: eebbed7a5e1c6b3318bcbe6525ea80d900ee1f12\n" ]
2016-11-11T06:51:41
2016-11-11T21:45:40
2016-11-11T21:45:40
CONTRIBUTOR
null
I'm using PostgreSQL. In one of my models I try to declare field named `tableoid`. This is a special field in PostgreSQL which is created automatically. So this always works: ```sql select foo.tableoid from foo; ``` But the field cannot be created manually: ```sql create table foo (tableoid int); -- ERROR: column name "tableoid" conflicts with a system column name ``` Yet I need to make Peewee aware of this field because when using [table inheritance](https://www.postgresql.org/docs/current/static/ddl-inherit.html) it is very convenient to join system tables and get tablenames by `tableoid`. Could you please make something like `Field(..., omit_creation=True)` for this situation?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1128/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1128/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1127
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1127/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1127/comments
https://api.github.com/repos/coleifer/peewee/issues/1127/events
https://github.com/coleifer/peewee/issues/1127
188,630,656
MDU6SXNzdWUxODg2MzA2NTY=
1,127
Postgres serial column but not primary key
{ "login": "chuckhacker", "id": 143290, "node_id": "MDQ6VXNlcjE0MzI5MA==", "avatar_url": "https://avatars.githubusercontent.com/u/143290?v=4", "gravatar_id": "", "url": "https://api.github.com/users/chuckhacker", "html_url": "https://github.com/chuckhacker", "followers_url": "https://api.github.com/users/chuckhacker/followers", "following_url": "https://api.github.com/users/chuckhacker/following{/other_user}", "gists_url": "https://api.github.com/users/chuckhacker/gists{/gist_id}", "starred_url": "https://api.github.com/users/chuckhacker/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/chuckhacker/subscriptions", "organizations_url": "https://api.github.com/users/chuckhacker/orgs", "repos_url": "https://api.github.com/users/chuckhacker/repos", "events_url": "https://api.github.com/users/chuckhacker/events{/privacy}", "received_events_url": "https://api.github.com/users/chuckhacker/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Adding a custom field is extremely easy: http://docs.peewee-orm.com/en/latest/peewee/models.html#creating-a-custom-field\n\nI think that's probably what you'll want to do, add a `SerialField`.\n", "Thanks, that's very helpful (although a trivial, common built-in type like `serial` should have already a `SerialField` in pg ootb IMO)!\r\n", "Glad to have been helpful!\n" ]
2016-11-10T22:02:59
2017-02-02T19:33:12
2016-11-11T06:12:47
NONE
null
`PrimaryKeyField` maps to the Postgres `serial` type, but it appears that there are indeed extra semantics forcing it to be a primary key (after all, one would guess that would be the case, given the name _PrimaryKey_Field). Since I already have another field that is a primary key (but is not a serial, yeah, I know...), I tried overriding these extra semantics using `primary_key=False` (after all, to me fields seem like they should just be mappings to DB types with minimal semantics, but maybe that goes against the whole philosophy of an ORM). However, despite my best intentions, this didn't work: ``` chuck@excelsior ~/matchmaking_webrtc $ ./run.sh Traceback (most recent call last): File "main.py", line 122, in <module> class User(BaseModel): File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4454, in __new__ raise ValueError('primary key is overdetermined.') ValueError: primary key is overdetermined. ``` How can I specify a field should be a `serial` without it being a primary key (I already have another primary key field)? Maybe we need to add a `SerialField` or the ability to set `primary_key` to `False` to override the extra implicit behavior of a `PrimaryKeyField` since it IS possible to do so in Postgres?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1127/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1127/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1126
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1126/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1126/comments
https://api.github.com/repos/coleifer/peewee/issues/1126/events
https://github.com/coleifer/peewee/pull/1126
188,501,046
MDExOlB1bGxSZXF1ZXN0OTMxNDUwNzM=
1,126
Make pskel script installable under usr/bin/
{ "login": "stratakis", "id": 14812606, "node_id": "MDQ6VXNlcjE0ODEyNjA2", "avatar_url": "https://avatars.githubusercontent.com/u/14812606?v=4", "gravatar_id": "", "url": "https://api.github.com/users/stratakis", "html_url": "https://github.com/stratakis", "followers_url": "https://api.github.com/users/stratakis/followers", "following_url": "https://api.github.com/users/stratakis/following{/other_user}", "gists_url": "https://api.github.com/users/stratakis/gists{/gist_id}", "starred_url": "https://api.github.com/users/stratakis/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/stratakis/subscriptions", "organizations_url": "https://api.github.com/users/stratakis/orgs", "repos_url": "https://api.github.com/users/stratakis/repos", "events_url": "https://api.github.com/users/stratakis/events{/privacy}", "received_events_url": "https://api.github.com/users/stratakis/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Thanks!\n" ]
2016-11-10T12:53:11
2016-11-10T17:33:55
2016-11-10T17:33:51
CONTRIBUTOR
null
Currently since pskel script does not have the .py extension, nothing happens when invoking setup.py install with that script. It just exists at the sources. The simplest way to make this script get installed is by adding it at the scripts sections in setup.py, thus making it installable under usr/bin/.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1126/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1126/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1126", "html_url": "https://github.com/coleifer/peewee/pull/1126", "diff_url": "https://github.com/coleifer/peewee/pull/1126.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1126.patch", "merged_at": "2016-11-10T17:33:51" }
https://api.github.com/repos/coleifer/peewee/issues/1125
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1125/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1125/comments
https://api.github.com/repos/coleifer/peewee/issues/1125/events
https://github.com/coleifer/peewee/issues/1125
188,414,553
MDU6SXNzdWUxODg0MTQ1NTM=
1,125
aggregate_rows() [+ switch()] + get() don't play nicely
{ "login": "alexlatchford", "id": 628146, "node_id": "MDQ6VXNlcjYyODE0Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/628146?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexlatchford", "html_url": "https://github.com/alexlatchford", "followers_url": "https://api.github.com/users/alexlatchford/followers", "following_url": "https://api.github.com/users/alexlatchford/following{/other_user}", "gists_url": "https://api.github.com/users/alexlatchford/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexlatchford/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexlatchford/subscriptions", "organizations_url": "https://api.github.com/users/alexlatchford/orgs", "repos_url": "https://api.github.com/users/alexlatchford/repos", "events_url": "https://api.github.com/users/alexlatchford/events{/privacy}", "received_events_url": "https://api.github.com/users/alexlatchford/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "PS. I know this is likely to cause performance issues when used on large datasets but the joins I'm looking to make are not huge 2-3 rows in each so figured I'd try this syntax to bundle up the network calls into a single query :)\n", "This is documented, in [\"Using aggregate_rows\"](http://docs.peewee-orm.com/en/latest/peewee/querying.html#using-aggregate-rows) at the end of the section:\n\n> Do not mix calls to `aggregate_rows()` with `LIMIT` or `OFFSET` clauses, or with `get()` (which applies a `LIMIT 1` SQL clause). Since the aggregate result set may contain more than one item due to rows being duplicated, limits can lead to incorrect behavior. Imagine you have three users, each of whom has 10 tweets. If you run a query with a `LIMIT 5`, then you will only receive the first user and their first 5 tweets.\n\nYour best bet is to use `prefetch` with a `LIMIT 1` on the outer-most query.\n" ]
2016-11-10T03:53:38
2016-11-13T22:31:16
2016-11-13T22:31:16
CONTRIBUTOR
null
Not sure if this is a documented feature, but I'd love to use it if it was! Essentially prefetch for `get()` :D If you're trying to aggregate multiple joins and backtracking using the `switch()` this results in some unexpected behaviour. ```python from peewee import * db = SqliteDatabase(":memory:") db.connect() class BaseModel(Model): class Meta: database = db class MyModel(BaseModel): id = PrimaryKeyField() class MyRelModel1(BaseModel): id = PrimaryKeyField() my_model = ForeignKeyField(MyModel, related_name="my_rel_models1") class MyRelModel2(BaseModel): id = PrimaryKeyField() my_model = ForeignKeyField(MyModel, related_name="my_rel_models2") MyModel.create_table() MyRelModel1.create_table() MyRelModel2.create_table() m1 = MyModel.create() MyRelModel1.create(my_model=m1) MyRelModel1.create(my_model=m1) MyRelModel1.create(my_model=m1) MyRelModel2.create(my_model=m1) MyRelModel2.create(my_model=m1) MyRelModel2.create(my_model=m1) my_model = MyModel.select( MyModel, MyRelModel1, MyRelModel2 ).join(MyRelModel1).switch(MyModel).join(MyRelModel2).aggregate_rows().get() print MyRelModel1.select().count() # 3 print MyRelModel2.select().count() # 3 print len(my_model.my_rel_models1) # 1 print len(my_model.my_rel_models2) # 1 ``` Now if I try to access `my_model.my_rel_models1` it will only give back a single result instead of the 3 as expected. I actually cannot get this to work either without the switch: ```python my_model = MyModel.select( MyModel, MyRelModel1 ).join(MyRelModel1).aggregate_rows().get() print len(my_model.my_rel_models1) # 1 ``` Thanks, Alex
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1125/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1125/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1124
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1124/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1124/comments
https://api.github.com/repos/coleifer/peewee/issues/1124/events
https://github.com/coleifer/peewee/issues/1124
188,408,027
MDU6SXNzdWUxODg0MDgwMjc=
1,124
the field can't named 'model'?
{ "login": "msean", "id": 13687394, "node_id": "MDQ6VXNlcjEzNjg3Mzk0", "avatar_url": "https://avatars.githubusercontent.com/u/13687394?v=4", "gravatar_id": "", "url": "https://api.github.com/users/msean", "html_url": "https://github.com/msean", "followers_url": "https://api.github.com/users/msean/followers", "following_url": "https://api.github.com/users/msean/following{/other_user}", "gists_url": "https://api.github.com/users/msean/gists{/gist_id}", "starred_url": "https://api.github.com/users/msean/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/msean/subscriptions", "organizations_url": "https://api.github.com/users/msean/orgs", "repos_url": "https://api.github.com/users/msean/repos", "events_url": "https://api.github.com/users/msean/events{/privacy}", "received_events_url": "https://api.github.com/users/msean/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2016-11-10T02:53:16
2016-11-10T02:58:55
2016-11-10T02:58:55
NONE
null
In Test Model,It set a field named 'model': `class Test(peewee.Model): model = peewee.CharField(max_length=64, null=True) class Meta: database = DATABASE db_table = 'test' schema = 'opr' ` It happened error : `File "/home/mwh/py3workplace/workplace/ad_tornado/handlers/opr.py", line 78, in post yield from self.db.create(Test,model='android') TypeError: create() got multiple values for argument 'model'` I used peewee to related some Tables which had establishd and contains field 'model',but It happend error like this...if I don't change the field in db,is there any other ideas?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1124/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1124/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1123
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1123/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1123/comments
https://api.github.com/repos/coleifer/peewee/issues/1123/events
https://github.com/coleifer/peewee/issues/1123
188,408,016
MDU6SXNzdWUxODg0MDgwMTY=
1,123
the field can't named 'model'?
{ "login": "msean", "id": 13687394, "node_id": "MDQ6VXNlcjEzNjg3Mzk0", "avatar_url": "https://avatars.githubusercontent.com/u/13687394?v=4", "gravatar_id": "", "url": "https://api.github.com/users/msean", "html_url": "https://github.com/msean", "followers_url": "https://api.github.com/users/msean/followers", "following_url": "https://api.github.com/users/msean/following{/other_user}", "gists_url": "https://api.github.com/users/msean/gists{/gist_id}", "starred_url": "https://api.github.com/users/msean/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/msean/subscriptions", "organizations_url": "https://api.github.com/users/msean/orgs", "repos_url": "https://api.github.com/users/msean/repos", "events_url": "https://api.github.com/users/msean/events{/privacy}", "received_events_url": "https://api.github.com/users/msean/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Please take the 10seconds and format your code...\n", "In My Test Model,It set a field named 'model':\n\n```\nimport peewee\nclass Test(peewee.Model):\n model = peewee.CharField(max_length=64, null=True)\n class Meta:\n database = DATABASE\n db_table = 'test'\n schema = 'opr'\n```\n\nwhen I create a record,It happens an error:\n\n```\nFile \"/home/mwh/py3workplace/workplace/ad_tornado/handlers/opr.py\", line 78, in post yield from \n\n self.db.create(Test,model='android') TypeError: create() got multiple values for argument ‘model’\n```\n\nWeather the filed can named 'model'?@coleifer \nI used peewee to related some Tables which had establishd and contains field 'model',\nif I don't change the field in db,is there any other ideas?\n", "I think the issue is in your code. There is no \"Database.create\" method in Peewee. It appears to be a function in your own application. :astonished: :trollface: \n" ]
2016-11-10T02:53:07
2016-11-10T17:39:44
2016-11-10T17:38:25
NONE
null
In Test Model,It set a field named 'model': class Test(peewee.Model): model = peewee.CharField(max_length=64, null=True) class Meta: database = DATABASE db_table = "test" schema = "opr" It happened error : `File "/home/mwh/py3workplace/workplace/ad_tornado/handlers/opr.py", line 78, in post yield from self.db.create(Test,model='android') TypeError: create() got multiple values for argument ‘model’ ` I used peewee to related some Tables which had establishd and contains field 'model',but It happend error like this...if I don't change the field in db,is there any other ideas?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1123/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1123/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1122
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1122/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1122/comments
https://api.github.com/repos/coleifer/peewee/issues/1122/events
https://github.com/coleifer/peewee/pull/1122
188,288,362
MDExOlB1bGxSZXF1ZXN0OTI5OTMwOTQ=
1,122
Fix pskel print statement for python3 compatibility
{ "login": "stratakis", "id": 14812606, "node_id": "MDQ6VXNlcjE0ODEyNjA2", "avatar_url": "https://avatars.githubusercontent.com/u/14812606?v=4", "gravatar_id": "", "url": "https://api.github.com/users/stratakis", "html_url": "https://github.com/stratakis", "followers_url": "https://api.github.com/users/stratakis/followers", "following_url": "https://api.github.com/users/stratakis/following{/other_user}", "gists_url": "https://api.github.com/users/stratakis/gists{/gist_id}", "starred_url": "https://api.github.com/users/stratakis/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/stratakis/subscriptions", "organizations_url": "https://api.github.com/users/stratakis/orgs", "repos_url": "https://api.github.com/users/stratakis/repos", "events_url": "https://api.github.com/users/stratakis/events{/privacy}", "received_events_url": "https://api.github.com/users/stratakis/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Whoops! Thank you.\n" ]
2016-11-09T16:21:47
2016-11-09T16:42:19
2016-11-09T16:42:15
CONTRIBUTOR
null
Invoking pskel under python3 produces an error due to the usage of print statement without parenthesis.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1122/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1122/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1122", "html_url": "https://github.com/coleifer/peewee/pull/1122", "diff_url": "https://github.com/coleifer/peewee/pull/1122.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1122.patch", "merged_at": "2016-11-09T16:42:15" }
https://api.github.com/repos/coleifer/peewee/issues/1121
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1121/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1121/comments
https://api.github.com/repos/coleifer/peewee/issues/1121/events
https://github.com/coleifer/peewee/issues/1121
187,903,128
MDU6SXNzdWUxODc5MDMxMjg=
1,121
Issue using FlaskDB and create_tables
{ "login": "bwghughes", "id": 7694, "node_id": "MDQ6VXNlcjc2OTQ=", "avatar_url": "https://avatars.githubusercontent.com/u/7694?v=4", "gravatar_id": "", "url": "https://api.github.com/users/bwghughes", "html_url": "https://github.com/bwghughes", "followers_url": "https://api.github.com/users/bwghughes/followers", "following_url": "https://api.github.com/users/bwghughes/following{/other_user}", "gists_url": "https://api.github.com/users/bwghughes/gists{/gist_id}", "starred_url": "https://api.github.com/users/bwghughes/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/bwghughes/subscriptions", "organizations_url": "https://api.github.com/users/bwghughes/orgs", "repos_url": "https://api.github.com/users/bwghughes/repos", "events_url": "https://api.github.com/users/bwghughes/events{/privacy}", "received_events_url": "https://api.github.com/users/bwghughes/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Subclassing `db_wrapper.model` obviates the need for a Meta: database definition. Furthermore, your \"Meta\" database should always be the un-wrapped Peewee db.\n\nThis is sufficient, though -- just remove the \"Meta\":\n\n```\nclass JobCodeEntry(db_wrapper.Model):\n date = DateField(default=date.today)\n code = CharField()\n```\n", "Thanks Charles !!\n\nOn Tue, 8 Nov 2016 at 07:18, Charles Leifer [email protected]\nwrote:\n\n> Subclassing db_wrapper.model obviates the need for a Meta: database\n> definition. Furthermore, your \"Meta\" database should always be the\n> un-wrapped Peewee db.\n> \n> This is sufficient, though -- just remove the \"Meta\":\n> \n> class JobCodeEntry(db_wrapper.Model):\n> date = DateField(default=date.today)\n> code = CharField()\n> \n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly, view it on GitHub\n> https://github.com/coleifer/peewee/issues/1121#issuecomment-259055392,\n> or mute the thread\n> https://github.com/notifications/unsubscribe-auth/AAAeDgK7eVEjD9YEZ4ZZF-R4pR_3Twbcks5q8BQ5gaJpZM4KsCiz\n> .\n" ]
2016-11-08T05:07:12
2016-11-08T10:56:32
2016-11-08T06:18:27
NONE
null
With the following code: ```python import os from datetime import date from flask import Flask, request, render_template from flask.views import MethodView from peewee import * from playhouse.flask_utils import FlaskDB import logging logging.basicConfig(level=logging.INFO) log = logging.getLogger(__name__) db_wrapper = FlaskDB() class JobCodeEntry(db_wrapper.Model): date = DateField(default=date.today) code = CharField() class Meta: database = db_wrapper class JCRTwilioHook(MethodView): def get(self): return render_template('index.html', entries=JobCodeEntry.select()) def post(self): JobCodeEntry.create({'code': request.form.get('Body')}) return 'OK' def create_app(): app = Flask(__name__) app.config['DATABASE'] = os.getenv('DATABASE_URL') db_wrapper.init_app(app) db_wrapper.database.create_tables([JobCodeEntry]) app.add_url_rule('/jcr/', view_func=JCRTwilioHook.as_view('jcr')) return app def main(): app = create_app() app.run(debug=True) if __name__ == '__main__': main() ``` I get the following error: ```python Traceback (most recent call last): File "app.py", line 46, in <module> main() File "app.py", line 42, in main app = create_app() File "app.py", line 37, in create_app db_wrapper.database.create_tables([JobCodeEntry]) File "/Users/ben/.pyenv/versions/jcr/lib/python3.5/site-packages/peewee.py", line 3772, in create_tables create_model_tables(models, fail_silently=safe) File "/Users/ben/.pyenv/versions/jcr/lib/python3.5/site-packages/peewee.py", line 5176, in create_model_tables m.create_table(**create_table_kwargs) File "/Users/ben/.pyenv/versions/jcr/lib/python3.5/site-packages/peewee.py", line 4853, in create_table if db.sequences and pk is not False and pk.sequence: AttributeError: 'FlaskDB' object has no attribute 'sequences' ``` It seems the API either isn't what I expected, or calling create_tables on the underlying database doesn't work as I thought. Thanks in advance !!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1121/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1121/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1120
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1120/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1120/comments
https://api.github.com/repos/coleifer/peewee/issues/1120/events
https://github.com/coleifer/peewee/issues/1120
187,771,472
MDU6SXNzdWUxODc3NzE0NzI=
1,120
Document (optional) requirements
{ "login": "vkrizan", "id": 7695766, "node_id": "MDQ6VXNlcjc2OTU3NjY=", "avatar_url": "https://avatars.githubusercontent.com/u/7695766?v=4", "gravatar_id": "", "url": "https://api.github.com/users/vkrizan", "html_url": "https://github.com/vkrizan", "followers_url": "https://api.github.com/users/vkrizan/followers", "following_url": "https://api.github.com/users/vkrizan/following{/other_user}", "gists_url": "https://api.github.com/users/vkrizan/gists{/gist_id}", "starred_url": "https://api.github.com/users/vkrizan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/vkrizan/subscriptions", "organizations_url": "https://api.github.com/users/vkrizan/orgs", "repos_url": "https://api.github.com/users/vkrizan/repos", "events_url": "https://api.github.com/users/vkrizan/events{/privacy}", "received_events_url": "https://api.github.com/users/vkrizan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Certainly, thanks for the nudge.\n" ]
2016-11-07T17:14:44
2016-11-08T02:05:17
2016-11-08T02:05:17
NONE
null
Please document (optional) requirements in one document (or file). This will help first-timers and help when packaging (RPM, deb). Requirements for playhouse extensions (so far I've identified these): ``` Cython # optional for speedups simplejson # optional for playhouse.kv and playhouse.sqlite_ext (json is supported since 2.6+ in standard lib) apsw # for playhouse.apsw_ext bz2 # optional for playhouse.fields zlib # optional for playhouse.fields Crypto # optional for playhouse.fields bcrypt # optional for playhouse.fields flask # (obviously) for playhouse.flask_utils psycopg2cffi # optional for playhouse.postgres_ext vtfunc # optional for playhouse.sqlite_udf (old import at sqlite_ext ?) gevent # optional for playhouse.sqliteq ``` Database drivers (Already noted in [Vendor Specific Parameters](http://docs.peewee-orm.com/en/latest/peewee/database.html#vendor-specific-parameters) in docs), could be noted in a table of supported databases and required drivers. ``` Mysql: MySQLdb or pymysql Postgres: psycopg2 Berkley: (optional) pysqlite2 ``` Thank you. I can help to create such document(s), although I am not sure when or why `simplejson` is needed.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1120/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1120/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1119
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1119/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1119/comments
https://api.github.com/repos/coleifer/peewee/issues/1119/events
https://github.com/coleifer/peewee/issues/1119
187,522,097
MDU6SXNzdWUxODc1MjIwOTc=
1,119
Set PostgreSQL schema in atomic
{ "login": "shanavar", "id": 1556149, "node_id": "MDQ6VXNlcjE1NTYxNDk=", "avatar_url": "https://avatars.githubusercontent.com/u/1556149?v=4", "gravatar_id": "", "url": "https://api.github.com/users/shanavar", "html_url": "https://github.com/shanavar", "followers_url": "https://api.github.com/users/shanavar/followers", "following_url": "https://api.github.com/users/shanavar/following{/other_user}", "gists_url": "https://api.github.com/users/shanavar/gists{/gist_id}", "starred_url": "https://api.github.com/users/shanavar/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/shanavar/subscriptions", "organizations_url": "https://api.github.com/users/shanavar/orgs", "repos_url": "https://api.github.com/users/shanavar/repos", "events_url": "https://api.github.com/users/shanavar/events{/privacy}", "received_events_url": "https://api.github.com/users/shanavar/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yes, you can simply set `MyModel._meta.schema`. I'm not sure what it means to run a transaction against one schema...or how that works. I guess I thought a table lived in one schema, so the idea of switching it's schema to do a transaction should imply you're working with an entirely different table??\n", "Yes. I am sorry, I did express myself the wrong way. What I wanted to say is, that I have one model that I use for multiple schemas so that all the tables do have the same structure but are of course different tables. And what I wanted is to set the schema within the atomic block, either for the whole transaction or per object/class. I wasn't sure if `User._meta.schema` wouldn't cause any problems if I use it in a peewee atomic block in a flask request or if it would simply set `tablename` to `schema.tablename` for queries inside this transaction only and have no effect otherwise.\n", "You're fine to modify the schema attribute, peewee will use whatever's set when the query is executed.\n" ]
2016-11-05T20:46:29
2016-11-07T13:13:44
2016-11-07T13:13:43
NONE
null
Hey everybody, so I got a problem regarding schema selection with peewee and PostgreSQL. I use peewee almost exclusively in transaction mode with `atomic`. While the schema is set to `none` in the meta of the class, I would want to set a specific schema in the `atomic` block. All queries in the atomic block should now act on the specified schema when the transaction of this `atomic` block happens. All the schemas in question do contain the same table structure. Is it possible to simply call `Model._meta.schema = myschema` at the beginning of the `atomic` block, e.g.: ```python class BaseModel(Model): name = CharField() class Meta: schema = none db_table = users with db.atomic() as txn: # set the schema for this block and the User Model User._meta.schema = myschema # this queries myschema.users and NOT public.users db.execute_sql('SELECT * FROM users WHERE name = %s', 'JohnDoe') # so does this User.create(name='JohnDoe') ``` So can I simply use `Model._meta.schema = myschema`? On the other hand, I also went through the documentation and a little bit through peewee source code and I think what I might need is some sort of `atomic` with properties of `Using` for schemas.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1119/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }
https://api.github.com/repos/coleifer/peewee/issues/1119/timeline
null
completed
null
null