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/1418
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1418/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1418/comments
https://api.github.com/repos/coleifer/peewee/issues/1418/events
https://github.com/coleifer/peewee/issues/1418
287,051,886
MDU6SXNzdWUyODcwNTE4ODY=
1,418
Cannot insert_many with optional fields
{ "login": "lukasni", "id": 5263957, "node_id": "MDQ6VXNlcjUyNjM5NTc=", "avatar_url": "https://avatars.githubusercontent.com/u/5263957?v=4", "gravatar_id": "", "url": "https://api.github.com/users/lukasni", "html_url": "https://github.com/lukasni", "followers_url": "https://api.github.com/users/lukasni/followers", "following_url": "https://api.github.com/users/lukasni/following{/other_user}", "gists_url": "https://api.github.com/users/lukasni/gists{/gist_id}", "starred_url": "https://api.github.com/users/lukasni/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/lukasni/subscriptions", "organizations_url": "https://api.github.com/users/lukasni/orgs", "repos_url": "https://api.github.com/users/lukasni/repos", "events_url": "https://api.github.com/users/lukasni/events{/privacy}", "received_events_url": "https://api.github.com/users/lukasni/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Alternatively, row_dict would have to be generated for every row, which could result in a significant slowdown.\r\n\r\nActually, looking over it again, neither this nor the option above will work. The suggestion from the original issue will fail to insert optional fields if the first inserted row doesn't have all optional fields defined, generating row_dict for every row will result in uneven VALUES parameters, which will fail on insert.\r\n\r\nThis could be a decent substitute: \r\n```python\r\nif not have_fields:\r\n fields = list(set().union(*(row.keys() for row in query._iter_rows())))\r\n fields.sort()\r\n have_fields = True\r\n```", "As you pointed out, a bulk insert query cannot have different values clauses as far as I know, so the difference has to be made up at query construction time... I'll give it some thought.", "@coleifer I currently have it running with the above code on L2104 and onwards, passes tests and seems to perform as expected. Basically just builds a fields list using the set of all keys in the dict, only happens once per query, so the performance impact shouldn't be too huge, though it doesn't scale too well for very large insert sets.", "> though it doesn't scale too well for very large insert sets.\r\n\r\nExactly the problem.", "Check out dd0af77a51b660a8804c6c97115f57d9596e54f2 in 3.0a branch.", "Think I'm going to close this one, as it should be resolved (generally) for 3.0a." ]
2018-01-09T11:11:09
2018-01-22T22:06:59
2018-01-22T22:06:59
NONE
null
Model.insert_many() fails if the keys of optional fields are omitted in the dictionary, specifically if _some_ of the objects contain the optional keys and some do not: Example --------- ```python db = SqliteDatabase('test.db') class MyModel(Model): my_id = PrimaryKeyField() required_field = CharField() optional_field = TextField(null=True) class Meta: database = db ``` ```python entity_list = [ { 'my_id': 12345, 'required_field': 'Test', 'optional_field': 'Test Text'}, { 'my_id': 12346, 'required_field': 'Test2'} ] with db.atomic(): MyModel.insert_many(entity_list).execute() ``` Observed Result ----------------- `KeyError` triggered in `QueryCompiler.generate_insert()`, specifically [peewee.py#L2111](https://github.com/coleifer/peewee/blob/cacb86a2ee6c808ebda1062be53f5824aa847f48/peewee.py#L2111) Expected Result ---------------- Records `12345` and `12346` created in table `test.mymodel`. Might be achievable by simply changing the line linked above to `value = row_dict.get(field, None)`, preliminary test is promising.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1418/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/1418/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1417
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1417/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1417/comments
https://api.github.com/repos/coleifer/peewee/issues/1417/events
https://github.com/coleifer/peewee/issues/1417
286,174,115
MDU6SXNzdWUyODYxNzQxMTU=
1,417
paginate function return data is error
{ "login": "aofengli", "id": 22781840, "node_id": "MDQ6VXNlcjIyNzgxODQw", "avatar_url": "https://avatars.githubusercontent.com/u/22781840?v=4", "gravatar_id": "", "url": "https://api.github.com/users/aofengli", "html_url": "https://github.com/aofengli", "followers_url": "https://api.github.com/users/aofengli/followers", "following_url": "https://api.github.com/users/aofengli/following{/other_user}", "gists_url": "https://api.github.com/users/aofengli/gists{/gist_id}", "starred_url": "https://api.github.com/users/aofengli/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/aofengli/subscriptions", "organizations_url": "https://api.github.com/users/aofengli/orgs", "repos_url": "https://api.github.com/users/aofengli/repos", "events_url": "https://api.github.com/users/aofengli/events{/privacy}", "received_events_url": "https://api.github.com/users/aofengli/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2018-01-05T02:31:54
2018-01-05T03:15:07
2018-01-05T03:15:00
NONE
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1417/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/1417/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1416
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1416/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1416/comments
https://api.github.com/repos/coleifer/peewee/issues/1416/events
https://github.com/coleifer/peewee/issues/1416
285,952,423
MDU6SXNzdWUyODU5NTI0MjM=
1,416
peewee .OperationalError: unknown tokenizer: icu zh_CN ( the same as #1371)
{ "login": "Shazoo", "id": 3198471, "node_id": "MDQ6VXNlcjMxOTg0NzE=", "avatar_url": "https://avatars.githubusercontent.com/u/3198471?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Shazoo", "html_url": "https://github.com/Shazoo", "followers_url": "https://api.github.com/users/Shazoo/followers", "following_url": "https://api.github.com/users/Shazoo/following{/other_user}", "gists_url": "https://api.github.com/users/Shazoo/gists{/gist_id}", "starred_url": "https://api.github.com/users/Shazoo/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Shazoo/subscriptions", "organizations_url": "https://api.github.com/users/Shazoo/orgs", "repos_url": "https://api.github.com/users/Shazoo/repos", "events_url": "https://api.github.com/users/Shazoo/events{/privacy}", "received_events_url": "https://api.github.com/users/Shazoo/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You don't have the \"icu\" tokenizer, as the error states.", "http://site.icu-project.org" ]
2018-01-04T11:15:59
2018-01-05T20:28:48
2018-01-05T20:28:48
NONE
null
Hi , I installed peewee via: ```bash git clone ....; cd peewee python setup.py build_ext ``` but it raise peewee.OperationalError: unknown tokenizer: icu zh_CN. I checked the issue 1371 https://github.com/coleifer/peewee/issues/1371 Tried the code mentioned , but it failed... ```python >>> import sqlite3 >>> conn = sqlite3.connect(':memory:') >>> conn.execute('CREATE VIRTUAL TABLE thai_text USING fts4 (content, tokenize=icu th_TH);') Traceback (most recent call last): File "<stdin>", line 1, in <module> sqlite3.OperationalError: unknown tokenizer: icu ``` so , anything wrong ? Thanks
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1416/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/1416/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1415
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1415/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1415/comments
https://api.github.com/repos/coleifer/peewee/issues/1415/events
https://github.com/coleifer/peewee/issues/1415
285,376,870
MDU6SXNzdWUyODUzNzY4NzA=
1,415
insert_many get error "KeyError('"%s" is not a recognized field.' % field)" while same data can be stored by mode.save
{ "login": "cn-qlg", "id": 15536545, "node_id": "MDQ6VXNlcjE1NTM2NTQ1", "avatar_url": "https://avatars.githubusercontent.com/u/15536545?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cn-qlg", "html_url": "https://github.com/cn-qlg", "followers_url": "https://api.github.com/users/cn-qlg/followers", "following_url": "https://api.github.com/users/cn-qlg/following{/other_user}", "gists_url": "https://api.github.com/users/cn-qlg/gists{/gist_id}", "starred_url": "https://api.github.com/users/cn-qlg/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cn-qlg/subscriptions", "organizations_url": "https://api.github.com/users/cn-qlg/orgs", "repos_url": "https://api.github.com/users/cn-qlg/repos", "events_url": "https://api.github.com/users/cn-qlg/events{/privacy}", "received_events_url": "https://api.github.com/users/cn-qlg/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Correct:\r\nScheduleDetail.insert_many(sch_details, validate_fields=True).execute(). But another error is raised \"KeyError: '\"scheduleDate\" is not a recognized field.\"\r\n\r\n---\r\n```ScheduleDetail.insert_many(sch_details, validate_fields=False).execute()```, when use validate_fields=False, it said \"AttributeError: 'str' object has no attribute '_sort_key'\"", "Use `boxId` instead of `boxId_id`. Also, did you happen to try this on Peewee 3.0a? Furthermore, `scheduleDate` is not a recognized field, so you should not include it in the `insert_many()` call.", "I used boxId_id instead of boxId, it was because in the before, some errors were raised when created tables, said that something wrong with boxId(The detail error message I forgot.), and then I found in the table, the field changed to 'boxId_id', so I try to use boxId_id, and happen to work.\r\nAnyway, thanks a lot." ]
2018-01-02T08:31:04
2018-01-03T16:15:13
2018-01-03T16:15:13
NONE
null
The original code like this: ``` detail = {'bookingCountStatus': 1, 'endTime': '2018-01-02 20:40:00', 'classid': '5584', 'startTime': '2018-01-02 19:40:00', 'tag': 'BBB', 'scheduleId': '40089221', 'boxId_id': 1024, 'supermonkeyCardPrice': 4275, 'scheduleDate': '2018-01-02', 'price': 4500, 'className': 'AAA'} sch = ScheduleDetail.create(**detail) sch.save() sch_details = [] sch_details.append(detail) if len(sch_details) > 0: with database.atomic(): ScheduleDetail.insert_many(sch_details).execute() database.close() ``` If I use Mode.create, and then call save(), it can work. But, there are more than 1 records, so I need to use insert_many(), but KeyError was raised. ``` Traceback (most recent call last): File "C:\Users\aaa\Desktop\Work\Python\bbb.py", line 110, in <module> get_schedule_detail('40089221') File "C:\Users\aaa\Desktop\Work\Python\bbb.py", line 86, in get_schedule_detail ScheduleDetail.insert_many(sch_details).execute() File "C:\Users\aaa\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 3584, in execute cursor = self._execute() File "C:\Users\aaa\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 2938, in _execute sql, params = self.sql() File "C:\Users\aaa\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 3552, in sql return self.compiler().generate_insert(self) File "C:\Users\aaa\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 2103, in generate_insert for row_dict in query._iter_rows(): File "C:\Users\aaa\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 3504, in _iter_rows validate_field(key) File "C:\Users\aaa\AppData\Local\Programs\Python\Python35-32\lib\site-packages\peewee.py", line 3494, in validate_field raise KeyError('"%s" is not a recognized field.' % field) KeyError: '"boxId_id" is not a recognized field.' [Finished in 1.5s with exit code 1] ``` Some more information about the Model definition. ``` class BoxInfo(BaseModel): """docstring for BoxInfo""" boxId = IntegerField(primary_key=True) boxname = CharField(null=True) city = CharField(null=True) address = CharField(null=True) class ScheduleDetail(BaseModel): scheduleId = CharField(null=True) classid = CharField(null=True) boxId = ForeignKeyField(BoxInfo, to_field='boxId') endTime = CharField(null=True) startTime = CharField(null=True) bookingCountStatus = CharField(null=True) price = CharField(null=True) supermonkeyCardPrice = CharField(null=True) classIntroduce = CharField(null=True) suitablePeople = CharField(null=True) trainingEffect = CharField(null=True) className = CharField(null=True) tag = CharField(null=True) ``` I am not sure if it is a bug, or something else. And I try to debug it, I find insert_many() will call validate_field() method, while Model.create().save() not. So, I add a parameter to insert_many(), like this ```ScheduleDetail.insert_many(sch_details, validate_fields=True).execute()```. But another error is raised "KeyError: '"scheduleDate" is not a recognized field." Env: Windows 10 + python 3.5.2 + peewee 2.10.0
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1415/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/1415/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1414
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1414/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1414/comments
https://api.github.com/repos/coleifer/peewee/issues/1414/events
https://github.com/coleifer/peewee/issues/1414
285,254,871
MDU6SXNzdWUyODUyNTQ4NzE=
1,414
MYSQL: TimeField returns datetime.time object instead of datetime.timedelta object
{ "login": "mos87", "id": 10418496, "node_id": "MDQ6VXNlcjEwNDE4NDk2", "avatar_url": "https://avatars.githubusercontent.com/u/10418496?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mos87", "html_url": "https://github.com/mos87", "followers_url": "https://api.github.com/users/mos87/followers", "following_url": "https://api.github.com/users/mos87/following{/other_user}", "gists_url": "https://api.github.com/users/mos87/gists{/gist_id}", "starred_url": "https://api.github.com/users/mos87/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mos87/subscriptions", "organizations_url": "https://api.github.com/users/mos87/orgs", "repos_url": "https://api.github.com/users/mos87/repos", "events_url": "https://api.github.com/users/mos87/events{/privacy}", "received_events_url": "https://api.github.com/users/mos87/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Yes, this is documented. You can very easily add your own `IntervalField` implementation.\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/models.html#creating-a-custom-field" ]
2017-12-31T12:22:42
2017-12-31T15:18:54
2017-12-31T15:18:54
NONE
null
I have the following construction: ``` class Config(Model): id = IntegerField(primary_key=True) # primary key = unique id date = DateField() time = TimeField() class Meta: database = db db_table = 'config' def getRepetitiveIntervall(): return Config.get(Config.id == 2).time ``` The time object is from type datetime.time instead of timedelta as it is in MYSQL If i set the value in the DB to 100:00:00 (4 days, 4 hours) the peewee TimeField only returns only the 4 hours as a time object instead of a timedelta object with the 4 days...
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1414/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/1414/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1413
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1413/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1413/comments
https://api.github.com/repos/coleifer/peewee/issues/1413/events
https://github.com/coleifer/peewee/pull/1413
285,178,848
MDExOlB1bGxSZXF1ZXN0MTYwNTc2MTEw
1,413
Update metadata.rst
{ "login": "sigma65535", "id": 18111133, "node_id": "MDQ6VXNlcjE4MTExMTMz", "avatar_url": "https://avatars.githubusercontent.com/u/18111133?v=4", "gravatar_id": "", "url": "https://api.github.com/users/sigma65535", "html_url": "https://github.com/sigma65535", "followers_url": "https://api.github.com/users/sigma65535/followers", "following_url": "https://api.github.com/users/sigma65535/following{/other_user}", "gists_url": "https://api.github.com/users/sigma65535/gists{/gist_id}", "starred_url": "https://api.github.com/users/sigma65535/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/sigma65535/subscriptions", "organizations_url": "https://api.github.com/users/sigma65535/orgs", "repos_url": "https://api.github.com/users/sigma65535/repos", "events_url": "https://api.github.com/users/sigma65535/events{/privacy}", "received_events_url": "https://api.github.com/users/sigma65535/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Documentation changes that pertain only to 3.0a are contained in the 3.0a branch." ]
2017-12-30T02:29:48
2017-12-31T01:40:06
2017-12-30T04:34:48
NONE
null
from the attributes table of Meta , the property of Meta “db_table” should be “table_name”。
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1413/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/1413/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1413", "html_url": "https://github.com/coleifer/peewee/pull/1413", "diff_url": "https://github.com/coleifer/peewee/pull/1413.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1413.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1412
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1412/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1412/comments
https://api.github.com/repos/coleifer/peewee/issues/1412/events
https://github.com/coleifer/peewee/pull/1412
285,103,613
MDExOlB1bGxSZXF1ZXN0MTYwNTIzNzk2
1,412
Document exception hierarchy
{ "login": "zmwangx", "id": 4149852, "node_id": "MDQ6VXNlcjQxNDk4NTI=", "avatar_url": "https://avatars.githubusercontent.com/u/4149852?v=4", "gravatar_id": "", "url": "https://api.github.com/users/zmwangx", "html_url": "https://github.com/zmwangx", "followers_url": "https://api.github.com/users/zmwangx/followers", "following_url": "https://api.github.com/users/zmwangx/following{/other_user}", "gists_url": "https://api.github.com/users/zmwangx/gists{/gist_id}", "starred_url": "https://api.github.com/users/zmwangx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/zmwangx/subscriptions", "organizations_url": "https://api.github.com/users/zmwangx/orgs", "repos_url": "https://api.github.com/users/zmwangx/repos", "events_url": "https://api.github.com/users/zmwangx/events{/privacy}", "received_events_url": "https://api.github.com/users/zmwangx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Cheers!", "Wow, that was fast. Thanks.", "For what it's worth, the peewee exceptions are based on those already documented in the DB-API 2.0 spec. https://www.python.org/dev/peps/pep-0249/#exceptions", "Good to know, thanks for the pointer." ]
2017-12-29T14:40:11
2017-12-29T14:44:27
2017-12-29T14:41:58
CONTRIBUTOR
null
Sometimes I want to make sure I'm catching all possible peewee exceptions, but not knowing the base exception makes it hard. Having the exception hierarchy in API docs (inspired by [docs for built-in exceptions][1]) could be handy for this. [1]: https://docs.python.org/3/library/exceptions.html#exception-hierarchy
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1412/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/1412/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1412", "html_url": "https://github.com/coleifer/peewee/pull/1412", "diff_url": "https://github.com/coleifer/peewee/pull/1412.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1412.patch", "merged_at": "2017-12-29T14:41:58" }
https://api.github.com/repos/coleifer/peewee/issues/1411
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1411/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1411/comments
https://api.github.com/repos/coleifer/peewee/issues/1411/events
https://github.com/coleifer/peewee/issues/1411
284,897,424
MDU6SXNzdWUyODQ4OTc0MjQ=
1,411
Allow on=SQL() when joining a table
{ "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
[ "You tried using Peewee 3.0a? I checked and it appears to work correctly.", "No, not yet." ]
2017-12-28T11:36:35
2017-12-28T16:55:18
2017-12-28T16:55:18
CONTRIBUTOR
null
Currently, it's impossible to make a join with `on=SQL('true')`, only with `on=Clause(SQL('true'))`. I believe this doesn't make enough sense. The problem is in `QueryCompiler.generate_joins()`.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1411/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/1411/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1410
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1410/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1410/comments
https://api.github.com/repos/coleifer/peewee/issues/1410/events
https://github.com/coleifer/peewee/issues/1410
284,861,056
MDU6SXNzdWUyODQ4NjEwNTY=
1,410
feature request: add validate schema in peewee model.
{ "login": "rfyiamcool", "id": 3785409, "node_id": "MDQ6VXNlcjM3ODU0MDk=", "avatar_url": "https://avatars.githubusercontent.com/u/3785409?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rfyiamcool", "html_url": "https://github.com/rfyiamcool", "followers_url": "https://api.github.com/users/rfyiamcool/followers", "following_url": "https://api.github.com/users/rfyiamcool/following{/other_user}", "gists_url": "https://api.github.com/users/rfyiamcool/gists{/gist_id}", "starred_url": "https://api.github.com/users/rfyiamcool/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rfyiamcool/subscriptions", "organizations_url": "https://api.github.com/users/rfyiamcool/orgs", "repos_url": "https://api.github.com/users/rfyiamcool/repos", "events_url": "https://api.github.com/users/rfyiamcool/events{/privacy}", "received_events_url": "https://api.github.com/users/rfyiamcool/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'll pass, I'm not even sure what validate schema means, btw." ]
2017-12-28T07:50:23
2017-12-28T16:54:37
2017-12-28T16:54:36
NONE
null
see title, thank U.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1410/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/1410/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1409
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1409/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1409/comments
https://api.github.com/repos/coleifer/peewee/issues/1409/events
https://github.com/coleifer/peewee/issues/1409
284,379,383
MDU6SXNzdWUyODQzNzkzODM=
1,409
[Question] Custom setter\callback for model fields
{ "login": "Nixellion", "id": 20309785, "node_id": "MDQ6VXNlcjIwMzA5Nzg1", "avatar_url": "https://avatars.githubusercontent.com/u/20309785?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Nixellion", "html_url": "https://github.com/Nixellion", "followers_url": "https://api.github.com/users/Nixellion/followers", "following_url": "https://api.github.com/users/Nixellion/following{/other_user}", "gists_url": "https://api.github.com/users/Nixellion/gists{/gist_id}", "starred_url": "https://api.github.com/users/Nixellion/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Nixellion/subscriptions", "organizations_url": "https://api.github.com/users/Nixellion/orgs", "repos_url": "https://api.github.com/users/Nixellion/repos", "events_url": "https://api.github.com/users/Nixellion/events{/privacy}", "received_events_url": "https://api.github.com/users/Nixellion/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can use Model.dirty_fields, which tracks changes to fields. Will that work?", "It could work, yes. However in a few functions I'm updating all fields and they all get dirty, even if information does not change.\r\n\r\nSo I ended up writing a function that uses `dict(self._data)` and compares current instance vs what's in the database before saving, and gives me only the fields where data is changed. So I'm doing it on save, and with dirty fields I'd have to move this check to another place.", "Cool, I suppose that works, but if it's comparing against what's in the database then doesn't that introduce both an additional query to each save() *and* a race condition?", "What's a race condition?\r\n\r\nAnd yes, indeed it does, and I'm slightly concerned about it. However in this project I don't expect very heavy use of the database, it should work even with SQLite, and I'm sure that MySQL server will handle much more than this. But if there's another solutio to reliably check changes, and whether the field data is actually different from what it was before, that would be great.", "Well, technically that's what `dirty_fields` is for. If you know which fields you're modifying and *don't* want them to be considered dirty, you can remove the field name from `model_instance._dirty` (a `set`). You can also do `model_instance._dirty.clear()` to reset the dirty fields at run-time. That's what I'd do. Anything more complicated gets pretty hairy.", "Well, as I said, I basically have a web form, which allows user to modify every field of the row. Once commited it updates every field. I will still need to perform comparison with existing data somewhere.", "I don't see what the harm is in saving most of the data in that case, but yea, I hear you.", "There's no harm in saving it, it's the fact that I send notifications when something is updated, and I need to know which fields were changed exactly." ]
2017-12-24T19:42:23
2017-12-26T23:31:44
2017-12-26T21:11:02
NONE
null
I'd like my application to send notifications whenever model is saved and certain fields are changed. I tried doing it by using `@var.setter` but naturally I can not just create a setter for peewee field, so I'd have to make separate set of variable\parameters, which gets quite bulky. I also read that I can override peewee Field classes with my own, but then I'll have to override each class, which does not seem like the best approach to me. So what other options are there in peewee\playhouse for this? Or which approach should I go with? Again, I tried looking through the docs, and googled it, no luck so far.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1409/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/1409/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1408
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1408/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1408/comments
https://api.github.com/repos/coleifer/peewee/issues/1408/events
https://github.com/coleifer/peewee/issues/1408
284,373,486
MDU6SXNzdWUyODQzNzM0ODY=
1,408
pwiz throwing peewee.ProgrammingError: op ANY/ALL (array) requires array on right side
{ "login": "idvorkin", "id": 280981, "node_id": "MDQ6VXNlcjI4MDk4MQ==", "avatar_url": "https://avatars.githubusercontent.com/u/280981?v=4", "gravatar_id": "", "url": "https://api.github.com/users/idvorkin", "html_url": "https://github.com/idvorkin", "followers_url": "https://api.github.com/users/idvorkin/followers", "following_url": "https://api.github.com/users/idvorkin/following{/other_user}", "gists_url": "https://api.github.com/users/idvorkin/gists{/gist_id}", "starred_url": "https://api.github.com/users/idvorkin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/idvorkin/subscriptions", "organizations_url": "https://api.github.com/users/idvorkin/orgs", "repos_url": "https://api.github.com/users/idvorkin/repos", "events_url": "https://api.github.com/users/idvorkin/events{/privacy}", "received_events_url": "https://api.github.com/users/idvorkin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "```psycopg2.ProgrammingError: op ANY/ALL (array) requires array on right side```\r\n\r\nCan you turn on SQL logging and print out the SQL that causes the problem?\r\n\r\n```python\r\nimport logging\r\nlogger = logging.getLogger('peewee')\r\nlogger.addHandler(logging.StreamHandler())\r\nlogger.setLevel(logging.DEBUG)\r\n```", "Oh wait, no need to, I found the SQL:\r\n\r\n```\r\n SELECT\r\n i.relname, idxs.indexdef, idx.indisunique,\r\n array_to_string(array_agg(cols.attname), ',')\r\n FROM pg_catalog.pg_class AS t\r\n INNER JOIN pg_catalog.pg_index AS idx ON t.oid = idx.indrelid\r\n INNER JOIN pg_catalog.pg_class AS i ON idx.indexrelid = i.oid\r\n INNER JOIN pg_catalog.pg_indexes AS idxs ON\r\n (idxs.tablename = t.relname AND idxs.indexname = i.relname)\r\n LEFT OUTER JOIN pg_catalog.pg_attribute AS cols ON\r\n (cols.attrelid = t.oid AND cols.attnum = ANY(idx.indkey))\r\n WHERE t.relname = %s AND t.relkind = %s AND idxs.schemaname = %s\r\n GROUP BY i.relname, idxs.indexdef, idx.indisunique\r\n ORDER BY idx.indisunique DESC, i.relname;\r\n```\r\n\r\nThis comes down to some difference in how redshift implements the SQL engine, I guess?\r\n\r\nI'd suggest subclassing `PostgresqlDatabase` and overriding the `get_indexes()` method with a working version of the above query. If you find a version that works on both regular postgres *and* redshift please let me know, I'd be happy to update the code.", "@coleifer attempting to do something similar as OP. \r\n\r\nI don't think Redshift really has the concept of indexes in the way that Postgres does\r\n\r\nhttps://www.stitchdata.com/blog/how-redshift-differs-from-postgresql/\r\n\r\n>Redshift doesn't support indexes. Instead, each table has a sort key, which determines how rows are ordered when the data is loaded. When you insert, update, or copy data in a Redshift table, new rows get added to an unsorted region, and are sorted only when the table is vacuumed or deep copied.\r\n\r\nWould it be advantageous to just no-op for `get_indexes()` during redshift? ", "You'll probably want to subclass-and-extend, as redshift is not supported as a first-class database by peewee. It's just happens to speak the postgres protocol and *mostly* works." ]
2017-12-24T17:09:45
2019-11-26T22:09:44
2017-12-26T19:15:49
NONE
null
Howdy, I'm trying to get pwiz to run against redshift. I'm starting by reflecting my database and have the following errors: Run pwiz over my redshift database: ``` idvor@IGORBASEMENTHP C:\Users\idvor > python -m pwiz <snip> Password: Traceback (most recent call last): File "C:\Users\idvor\Anaconda3\lib\site-packages\peewee.py", line 3830, in execute_sql cursor.execute(sql, params or ()) psycopg2.ProgrammingError: op ANY/ALL (array) requires array on right side During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\idvor\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\idvor\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\idvor\Anaconda3\lib\site-packages\pwiz.py", line 201, in <module> print_models(introspector, tables, preserve_order=options.preserve_order) File "C:\Users\idvor\Anaconda3\lib\site-packages\pwiz.py", line 47, in print_models database = introspector.introspect(table_names=tables) File "C:\Users\idvor\Anaconda3\lib\site-packages\playhouse\reflection.py", line 461, in introspect table_indexes = self.metadata.get_indexes(table, self.schema) File "C:\Users\idvor\Anaconda3\lib\site-packages\playhouse\reflection.py", line 256, in get_indexes return super(PostgresqlMetadata, self).get_indexes(table, schema) File "C:\Users\idvor\Anaconda3\lib\site-packages\playhouse\reflection.py", line 180, in get_indexes return self.database.get_indexes(table, schema) File "C:\Users\idvor\Anaconda3\lib\site-packages\peewee.py", line 4216, in get_indexes cursor = self.execute_sql(query, (table, 'r', schema)) File "C:\Users\idvor\Anaconda3\lib\site-packages\peewee.py", line 3837, in execute_sql self.commit() File "C:\Users\idvor\Anaconda3\lib\site-packages\peewee.py", line 3656, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "C:\Users\idvor\Anaconda3\lib\site-packages\peewee.py", line 135, in reraise raise value.with_traceback(tb) File "C:\Users\idvor\Anaconda3\lib\site-packages\peewee.py", line 3830, in execute_sql cursor.execute(sql, params or ()) peewee.ProgrammingError: op ANY/ALL (array) requires array on right side ``` My psql content is: ``` idvorkin1=# \d List of relations schema | name | type | owner --------+---------+-------+---------- public | account | table | idvorkin (1 row) idvorkin1=# \d account Table "public.account" Column | Type | Modifiers ------------+-----------------------------+----------- username | character varying(50) | not null password | character varying(50) | not null email | character varying(355) | not null created_on | timestamp without time zone | not null last_login | timestamp without time zone | Indexes: "account_email_key" UNIQUE, btree (email) "account_username_key" UNIQUE, btree (username) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1408/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/1408/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1407
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1407/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1407/comments
https://api.github.com/repos/coleifer/peewee/issues/1407/events
https://github.com/coleifer/peewee/issues/1407
284,236,842
MDU6SXNzdWUyODQyMzY4NDI=
1,407
Document insert_many().execute() behavior
{ "login": "vadimkantorov", "id": 1041752, "node_id": "MDQ6VXNlcjEwNDE3NTI=", "avatar_url": "https://avatars.githubusercontent.com/u/1041752?v=4", "gravatar_id": "", "url": "https://api.github.com/users/vadimkantorov", "html_url": "https://github.com/vadimkantorov", "followers_url": "https://api.github.com/users/vadimkantorov/followers", "following_url": "https://api.github.com/users/vadimkantorov/following{/other_user}", "gists_url": "https://api.github.com/users/vadimkantorov/gists{/gist_id}", "starred_url": "https://api.github.com/users/vadimkantorov/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/vadimkantorov/subscriptions", "organizations_url": "https://api.github.com/users/vadimkantorov/orgs", "repos_url": "https://api.github.com/users/vadimkantorov/repos", "events_url": "https://api.github.com/users/vadimkantorov/events{/privacy}", "received_events_url": "https://api.github.com/users/vadimkantorov/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It seems it's impossible to implement cleanly (`last_insert_rowid` etc) . So a note in the docs about the difference in behavior of `execute()` would be awesome.", "What database engine are you using?", "SQLite", "Yeah sqlite doesn't support the returning clause so you're out of luck." ]
2017-12-22T19:35:50
2018-01-08T10:29:38
2018-01-08T10:29:38
NONE
null
I'd like to bulk insert new Users in a table (peewee 2.10.2). I'm doing `User.insert_many([dict(display = 'u1'), dict(display = 'u2')]).execute()`. However, this returned boolean. How do I get primary id's for the newly inserted objects? I saw in the docs that `insert(...).execute()` will return an id, so I expected the bulk version does the same. Thanks!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1407/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/1407/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1406
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1406/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1406/comments
https://api.github.com/repos/coleifer/peewee/issues/1406/events
https://github.com/coleifer/peewee/issues/1406
284,223,933
MDU6SXNzdWUyODQyMjM5MzM=
1,406
[Question] ForeignKey to self
{ "login": "Nixellion", "id": 20309785, "node_id": "MDQ6VXNlcjIwMzA5Nzg1", "avatar_url": "https://avatars.githubusercontent.com/u/20309785?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Nixellion", "html_url": "https://github.com/Nixellion", "followers_url": "https://api.github.com/users/Nixellion/followers", "following_url": "https://api.github.com/users/Nixellion/following{/other_user}", "gists_url": "https://api.github.com/users/Nixellion/gists{/gist_id}", "starred_url": "https://api.github.com/users/Nixellion/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Nixellion/subscriptions", "organizations_url": "https://api.github.com/users/Nixellion/orgs", "repos_url": "https://api.github.com/users/Nixellion/repos", "events_url": "https://api.github.com/users/Nixellion/events{/privacy}", "received_events_url": "https://api.github.com/users/Nixellion/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "http://docs.peewee-orm.com/en/latest/peewee/models.html#self-referential-foreign-keys", "Thanks a lot, sorry I could not find it myself.", "No worries it's tricky if you aren't sure what to Google for." ]
2017-12-22T18:22:46
2017-12-23T23:32:36
2017-12-22T18:51:36
NONE
null
I'm trying to create a hierarchy of objects, and for that I need to have a foreign key to self class. Not to same instance, but to same class. So basically what I need is this: ``` class Object(Model): parent = ForeignKeyField(Object, related_name='children, null=False) ``` But naturally it does not work, since Object does not yet exist at that moment. How can I approach this problem? Could not find it in documentation, not sure how to call this issue even.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1406/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/1406/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1405
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1405/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1405/comments
https://api.github.com/repos/coleifer/peewee/issues/1405/events
https://github.com/coleifer/peewee/issues/1405
284,038,983
MDU6SXNzdWUyODQwMzg5ODM=
1,405
Foreign key fields without related attribute
{ "login": "vadimkantorov", "id": 1041752, "node_id": "MDQ6VXNlcjEwNDE3NTI=", "avatar_url": "https://avatars.githubusercontent.com/u/1041752?v=4", "gravatar_id": "", "url": "https://api.github.com/users/vadimkantorov", "html_url": "https://github.com/vadimkantorov", "followers_url": "https://api.github.com/users/vadimkantorov/followers", "following_url": "https://api.github.com/users/vadimkantorov/following{/other_user}", "gists_url": "https://api.github.com/users/vadimkantorov/gists{/gist_id}", "starred_url": "https://api.github.com/users/vadimkantorov/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/vadimkantorov/subscriptions", "organizations_url": "https://api.github.com/users/vadimkantorov/orgs", "repos_url": "https://api.github.com/users/vadimkantorov/repos", "events_url": "https://api.github.com/users/vadimkantorov/events{/privacy}", "received_events_url": "https://api.github.com/users/vadimkantorov/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can, in the model `Meta`, specify `validate_backrefs = False` to disable validation in 2.x.\r\n\r\nIf you're using 3.0a, validation is not enforced at the moment.\r\n\r\nI had not considered supporting disabling backrefs altogether, but that might be a good idea to add in 3.0a.", "In 3.0a, by specifying `backref='!'`, you can disable the addition of the backref accessor to the related model." ]
2017-12-22T00:06:02
2018-01-08T10:36:56
2018-01-08T10:36:56
NONE
null
I'd like to create a model that has two different foreign keys to another model. Peewee forces to use different `related_name`'s in order to make two different related Python attributes in the other model. In fact, I don't need those attributes. Is there a way to tell Peewee to skip creating these attributes? I tried setting `related_name = None`, but it didn't help. The usecase is modeling Audit records. I don't really care about conveniently retrieving all records by a given user using the Python code. I'll be just dumping all audit records to a spreadsheet and exploring it manually.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1405/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/1405/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1404
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1404/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1404/comments
https://api.github.com/repos/coleifer/peewee/issues/1404/events
https://github.com/coleifer/peewee/issues/1404
283,496,049
MDU6SXNzdWUyODM0OTYwNDk=
1,404
How to create temporary table in peewee??
{ "login": "ptoyhawinf", "id": 6279891, "node_id": "MDQ6VXNlcjYyNzk4OTE=", "avatar_url": "https://avatars.githubusercontent.com/u/6279891?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ptoyhawinf", "html_url": "https://github.com/ptoyhawinf", "followers_url": "https://api.github.com/users/ptoyhawinf/followers", "following_url": "https://api.github.com/users/ptoyhawinf/following{/other_user}", "gists_url": "https://api.github.com/users/ptoyhawinf/gists{/gist_id}", "starred_url": "https://api.github.com/users/ptoyhawinf/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ptoyhawinf/subscriptions", "organizations_url": "https://api.github.com/users/ptoyhawinf/orgs", "repos_url": "https://api.github.com/users/ptoyhawinf/repos", "events_url": "https://api.github.com/users/ptoyhawinf/events{/privacy}", "received_events_url": "https://api.github.com/users/ptoyhawinf/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "In peewee 3.0a you can pass `temporary=True` when calling create_table(). In 2.x you'll need to write the query by hand." ]
2017-12-20T09:17:26
2018-01-05T20:30:06
2018-01-05T20:30:06
NONE
null
HI I used your API for a long time. And I want to create temporary table in my application, however I can’t find any describe in the document. Could you give me some advice?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1404/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/1404/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1403
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1403/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1403/comments
https://api.github.com/repos/coleifer/peewee/issues/1403/events
https://github.com/coleifer/peewee/issues/1403
283,476,187
MDU6SXNzdWUyODM0NzYxODc=
1,403
ImportError: cannot import name PooledPostgresqlExtDatabase
{ "login": "toplinuxsir", "id": 1111353, "node_id": "MDQ6VXNlcjExMTEzNTM=", "avatar_url": "https://avatars.githubusercontent.com/u/1111353?v=4", "gravatar_id": "", "url": "https://api.github.com/users/toplinuxsir", "html_url": "https://github.com/toplinuxsir", "followers_url": "https://api.github.com/users/toplinuxsir/followers", "following_url": "https://api.github.com/users/toplinuxsir/following{/other_user}", "gists_url": "https://api.github.com/users/toplinuxsir/gists{/gist_id}", "starred_url": "https://api.github.com/users/toplinuxsir/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/toplinuxsir/subscriptions", "organizations_url": "https://api.github.com/users/toplinuxsir/orgs", "repos_url": "https://api.github.com/users/toplinuxsir/repos", "events_url": "https://api.github.com/users/toplinuxsir/events{/privacy}", "received_events_url": "https://api.github.com/users/toplinuxsir/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You probably need to install psycopg2 the postgres driver." ]
2017-12-20T07:48:00
2017-12-20T13:40:03
2017-12-20T13:40:03
NONE
null
Install peewee for python 2.7 on windows ``` from playhouse.pool import PooledPostgresqlExtDatabase ``` raise exception : ImportError: cannot import name PooledPostgresqlExtDatabase
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1403/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/1403/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1402
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1402/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1402/comments
https://api.github.com/repos/coleifer/peewee/issues/1402/events
https://github.com/coleifer/peewee/issues/1402
282,847,315
MDU6SXNzdWUyODI4NDczMTU=
1,402
External files
{ "login": "hugo-pires", "id": 7768784, "node_id": "MDQ6VXNlcjc3Njg3ODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/7768784?v=4", "gravatar_id": "", "url": "https://api.github.com/users/hugo-pires", "html_url": "https://github.com/hugo-pires", "followers_url": "https://api.github.com/users/hugo-pires/followers", "following_url": "https://api.github.com/users/hugo-pires/following{/other_user}", "gists_url": "https://api.github.com/users/hugo-pires/gists{/gist_id}", "starred_url": "https://api.github.com/users/hugo-pires/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/hugo-pires/subscriptions", "organizations_url": "https://api.github.com/users/hugo-pires/orgs", "repos_url": "https://api.github.com/users/hugo-pires/repos", "events_url": "https://api.github.com/users/hugo-pires/events{/privacy}", "received_events_url": "https://api.github.com/users/hugo-pires/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Sure...it's just Python?", "Thanks." ]
2017-12-18T11:29:53
2017-12-18T14:22:42
2017-12-18T14:20:32
NONE
null
Hello I am using peewee to run raw MySQL queries. Sometimes, I have to use some multi-lines and they take some space on python code files. May I read an external SQL file? Or a Python file with multiliners? Thank you
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1402/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/1402/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1401
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1401/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1401/comments
https://api.github.com/repos/coleifer/peewee/issues/1401/events
https://github.com/coleifer/peewee/issues/1401
282,028,810
MDU6SXNzdWUyODIwMjg4MTA=
1,401
Support of BINARY fields
{ "login": "conqp", "id": 3766192, "node_id": "MDQ6VXNlcjM3NjYxOTI=", "avatar_url": "https://avatars.githubusercontent.com/u/3766192?v=4", "gravatar_id": "", "url": "https://api.github.com/users/conqp", "html_url": "https://github.com/conqp", "followers_url": "https://api.github.com/users/conqp/followers", "following_url": "https://api.github.com/users/conqp/following{/other_user}", "gists_url": "https://api.github.com/users/conqp/gists{/gist_id}", "starred_url": "https://api.github.com/users/conqp/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/conqp/subscriptions", "organizations_url": "https://api.github.com/users/conqp/orgs", "repos_url": "https://api.github.com/users/conqp/repos", "events_url": "https://api.github.com/users/conqp/events{/privacy}", "received_events_url": "https://api.github.com/users/conqp/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I believe you should be fine to use `BlobField` for most things, but it is also very easy to subclass `BlobField` and provide an implementation for the data-type you wish to use.\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/models.html#creating-a-custom-field" ]
2017-12-14T09:11:18
2017-12-14T14:24:46
2017-12-14T14:24:46
CONTRIBUTOR
null
I was just searching the internet for possibilities to handle BINARY fields (MySQL) in peewee and came across [this](https://github.com/coleifer/peewee/issues/801). However, though the [respective pull request](https://github.com/coleifer/peewee/pull/802) was merged in 2015, I cannot find the respective code in peewee any longer and the official documentation also does not state any support of BINARY. What happend to its support and can it be added again?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1401/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/1401/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1400
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1400/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1400/comments
https://api.github.com/repos/coleifer/peewee/issues/1400/events
https://github.com/coleifer/peewee/issues/1400
281,011,019
MDU6SXNzdWUyODEwMTEwMTk=
1,400
Support enum.
{ "login": "alexpantyukhin", "id": 6513121, "node_id": "MDQ6VXNlcjY1MTMxMjE=", "avatar_url": "https://avatars.githubusercontent.com/u/6513121?v=4", "gravatar_id": "", "url": "https://api.github.com/users/alexpantyukhin", "html_url": "https://github.com/alexpantyukhin", "followers_url": "https://api.github.com/users/alexpantyukhin/followers", "following_url": "https://api.github.com/users/alexpantyukhin/following{/other_user}", "gists_url": "https://api.github.com/users/alexpantyukhin/gists{/gist_id}", "starred_url": "https://api.github.com/users/alexpantyukhin/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/alexpantyukhin/subscriptions", "organizations_url": "https://api.github.com/users/alexpantyukhin/orgs", "repos_url": "https://api.github.com/users/alexpantyukhin/repos", "events_url": "https://api.github.com/users/alexpantyukhin/events{/privacy}", "received_events_url": "https://api.github.com/users/alexpantyukhin/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "https://github.com/coleifer/peewee/issues/630" ]
2017-12-11T13:11:32
2017-12-11T15:25:03
2017-12-11T15:25:03
NONE
null
Python supports enums (https://docs.python.org/3/library/enum.html) I think it would be good to have it in the `choices` parameter.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1400/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/1400/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1399
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1399/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1399/comments
https://api.github.com/repos/coleifer/peewee/issues/1399/events
https://github.com/coleifer/peewee/issues/1399
280,976,279
MDU6SXNzdWUyODA5NzYyNzk=
1,399
Keep getting error: OperationalError: Database has not been initialized
{ "login": "XuyangBai", "id": 15166089, "node_id": "MDQ6VXNlcjE1MTY2MDg5", "avatar_url": "https://avatars.githubusercontent.com/u/15166089?v=4", "gravatar_id": "", "url": "https://api.github.com/users/XuyangBai", "html_url": "https://github.com/XuyangBai", "followers_url": "https://api.github.com/users/XuyangBai/followers", "following_url": "https://api.github.com/users/XuyangBai/following{/other_user}", "gists_url": "https://api.github.com/users/XuyangBai/gists{/gist_id}", "starred_url": "https://api.github.com/users/XuyangBai/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/XuyangBai/subscriptions", "organizations_url": "https://api.github.com/users/XuyangBai/orgs", "repos_url": "https://api.github.com/users/XuyangBai/repos", "events_url": "https://api.github.com/users/XuyangBai/events{/privacy}", "received_events_url": "https://api.github.com/users/XuyangBai/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Somehow I assume your dataService() object is not getting instantiated. There is a problem in your python code, not in Peewee.", "Hello, I checked my code again and found that the error `OperationalError: Database has not been initialized` just thrown when I was trying to `from model import db`. \r\nSo how could I import `db` without this error? ( Since my variable `db` and class `dataService` defined in two seperate files)" ]
2017-12-11T11:04:40
2017-12-12T02:08:26
2017-12-11T15:24:05
NONE
null
Hi, I have following code using SqliteQueueDatabase. But I keep getting error `OperationalError: Database has not been initialized` I tried several methods but nothing works. So would please help me with that? Thanks you : ) dataService.py ``` from model import db class dataService(object): def __init__(self, db_path): db.init(db_path) db.start() def some_func(self): pass ``` model.py ``` from playhouse.sqliteq import SqliteQueueDatabase db = SqliteQueueDatabase(None) class BaseModel(Model): class Meta(object): database = db class Item(BaseModel): city = CharField() district = CharField() ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1399/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/1399/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1398
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1398/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1398/comments
https://api.github.com/repos/coleifer/peewee/issues/1398/events
https://github.com/coleifer/peewee/issues/1398
280,339,516
MDU6SXNzdWUyODAzMzk1MTY=
1,398
No way to create a table by string?
{ "login": "josephmancuso", "id": 20172538, "node_id": "MDQ6VXNlcjIwMTcyNTM4", "avatar_url": "https://avatars.githubusercontent.com/u/20172538?v=4", "gravatar_id": "", "url": "https://api.github.com/users/josephmancuso", "html_url": "https://github.com/josephmancuso", "followers_url": "https://api.github.com/users/josephmancuso/followers", "following_url": "https://api.github.com/users/josephmancuso/following{/other_user}", "gists_url": "https://api.github.com/users/josephmancuso/gists{/gist_id}", "starred_url": "https://api.github.com/users/josephmancuso/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/josephmancuso/subscriptions", "organizations_url": "https://api.github.com/users/josephmancuso/orgs", "repos_url": "https://api.github.com/users/josephmancuso/repos", "events_url": "https://api.github.com/users/josephmancuso/events{/privacy}", "received_events_url": "https://api.github.com/users/josephmancuso/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What would it create if there were no columns defined?", "it could just create a table with an id column by default", "And what if you don't want the \"id\" column? Seems weird.", "`migrator.create_table('users', pk='user_id'),` \r\n", "Peewee already has APIs for creating tables -- going to pass on these suggestions." ]
2017-12-08T01:33:39
2017-12-10T21:58:19
2017-12-10T21:58:19
NONE
null
why is this not possible? ``` engine = database.engines['default'] migrator = MySQLMigrator(engine) engine.create_tables(['users'], True) <--- not possible migrate( migrator.add_column('users', 'column_name', 'CharField(default=255)'), ) engine.close() ``` is there no way to simply create a table based off of a string? I want to separate the models and the migrations from each other so that I don't need to create a model before I create a table for it. I would like to create tables without a model or even a way to do: `migrator.create_table('users', True),`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1398/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/1398/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1397
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1397/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1397/comments
https://api.github.com/repos/coleifer/peewee/issues/1397/events
https://github.com/coleifer/peewee/issues/1397
279,387,256
MDU6SXNzdWUyNzkzODcyNTY=
1,397
Extending JSON queries / building expression with JSON keys
{ "login": "tuukkamustonen", "id": 94327, "node_id": "MDQ6VXNlcjk0MzI3", "avatar_url": "https://avatars.githubusercontent.com/u/94327?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tuukkamustonen", "html_url": "https://github.com/tuukkamustonen", "followers_url": "https://api.github.com/users/tuukkamustonen/followers", "following_url": "https://api.github.com/users/tuukkamustonen/following{/other_user}", "gists_url": "https://api.github.com/users/tuukkamustonen/gists{/gist_id}", "starred_url": "https://api.github.com/users/tuukkamustonen/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tuukkamustonen/subscriptions", "organizations_url": "https://api.github.com/users/tuukkamustonen/orgs", "repos_url": "https://api.github.com/users/tuukkamustonen/repos", "events_url": "https://api.github.com/users/tuukkamustonen/events{/privacy}", "received_events_url": "https://api.github.com/users/tuukkamustonen/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You *should* just be able to write:\r\n\r\n```python\r\nData.select().where(Data.notes['org_path'] % '1/2/*')\r\n# ('SELECT \"t1\".\"id\", \"t1\".\"notes\" FROM \"data\" AS \"t1\" WHERE (\"t1\".\"notes\"->>%s LIKE %s)',\r\n# ['org_chart', '1/2/*'])\r\n```", "Uh, I'll try that. What how about _if_ I actually needed to build something more complex, where I would really face the problems in the original message?", "Can you give an example of a more complex query?", "Maybe using some more exotic json operators (or combination) from https://www.postgresql.org/docs/current/static/functions-json.html. I would assume not everything is supported out-of-box?", "*Most* of that stuff actually is supported, although there are probably some exceptions.\r\n\r\nTo your question, though... The `SQL()` constructor doesn't know about converting models or fields into quoted names. It treats everything after the SQL string itself as a parameter of the query.\r\n\r\nIf you wanted to dynamically construct a query, you might do something like:\r\n\r\n```python\r\n# 2.x\r\nexp = Clause(Data.notes, SQL('->>\"foobar\" LIKE %s', '1/2/*'), glue='')\r\n\r\n# 3.x\r\nexp = NodeList([\r\n Data.notes, \r\n SQL('->>\"foobar\" LIKE %s', ('1/2/*',))\r\n], glue='')\r\n\r\n# either\r\nData.select().where(exp)\r\n```", "Yeah, I see them now in `PostgresqlExtCompiler`. Most of the stuff that is not implemented is probably not needed after all (concat `||` and deletions `-`/`#-`).\r\n\r\nNone of the [JSON Processing Functions](https://www.postgresql.org/docs/current/static/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE) are supported, though? Some of those could be useful sometimes (though I'm not sure when/how).", "They are, just use `fn.json_function_name(...)`.", "Of course. Thanks again. `peewee` is awesome." ]
2017-12-05T14:07:08
2017-12-05T15:52:16
2017-12-05T15:22:50
NONE
null
I'm trying to query by single JSON field value with pattern matching (e.g. `ILIKE "foo*"`), something like: ```python class BaseModel(peewee.Model): class Meta(object): database = db class Data(BaseModel): notes = BinaryJsonField() # Create tables and indexes... Data.create(notes={'org_path': '1/1/1'}) Data.create(notes={'org_path': '1/2/1'}) Data.create(notes={'org_path': '1/2/2'}) ``` Trying to query them: ```python Data.select().where(SQL("Data.notes->>'org_path' LIKE '%s'", '1/2/*')) ``` ...because peewee maps `Data` table name as `t1` in query. If I manually write `t1` in there, it works. Is it possible to grab `t1` somehow into `SQL(...)` or how should I tackle this? Use `alias()` or something? Also tried: ```python Data.select().where(SQL("%s.notes->>'org_path' LIKE '%s'", '1/2/*', Data)) # fails into: ProgrammingError: can't adapt type 'BaseModel' ``` So maybe: ```python Data.select().where(SQL("%s->>'org_path' LIKE '%s'", '1/2/*', Data.notes)) # fails into: ProgrammingError: can't adapt type 'BinaryJSONField' ``` Also, to make these queries more "formal" I would like to build `Expression`s instead. For example, `BinaryJsonField#contains()` returns: ```python Expression(self, OP.JSONB_EXISTS, Passthrough(other)) ``` It would be easy to just change the operator, but I need to make `lhs`(`self`) map into `Data.notes->>'org_path'` and I'm not sure how/where to do that. Can I use `Data.notes['org_path']` somehow...?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1397/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/1397/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1396
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1396/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1396/comments
https://api.github.com/repos/coleifer/peewee/issues/1396/events
https://github.com/coleifer/peewee/issues/1396
278,900,615
MDU6SXNzdWUyNzg5MDA2MTU=
1,396
Model.get doesn't work when I pass a foreing key field attribute
{ "login": "yanghg-basefx", "id": 29534214, "node_id": "MDQ6VXNlcjI5NTM0MjE0", "avatar_url": "https://avatars.githubusercontent.com/u/29534214?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yanghg-basefx", "html_url": "https://github.com/yanghg-basefx", "followers_url": "https://api.github.com/users/yanghg-basefx/followers", "following_url": "https://api.github.com/users/yanghg-basefx/following{/other_user}", "gists_url": "https://api.github.com/users/yanghg-basefx/gists{/gist_id}", "starred_url": "https://api.github.com/users/yanghg-basefx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yanghg-basefx/subscriptions", "organizations_url": "https://api.github.com/users/yanghg-basefx/orgs", "repos_url": "https://api.github.com/users/yanghg-basefx/repos", "events_url": "https://api.github.com/users/yanghg-basefx/events{/privacy}", "received_events_url": "https://api.github.com/users/yanghg-basefx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Good catch...the `filter()` API is not very smart when it comes to self-referential foreign-keys. I had thought it would handle this simple case, but apparently I'm missing a unit-test (which would've revealed the issue).\r\n\r\nFor now, try:\r\n\r\n```python\r\nM.get(M.parent == 10000)\r\n```", "I've pushed a fix for this simple case in 3.0a. Unfortunately, lookups that traverse the self-referential FK will still have the join alias issue.", "It works fine! When the 3.0 branch become to stable, I will merge it into our company. Thanks!\r\n\r\nBut sorry, I can't really understand what does `lookups that traverse the self-referential FK will still have the join alias issue` mean. Can you give me a example? I can't reproduce it.\r\n\r\nI've tried this:\r\n\r\n```python\r\nMA = M.alias()\r\nMA.get(parent=10000)\r\n```\r\n\r\nIt still work.", "Or do you mean this?\r\n\r\n```python\r\nquery = M.select().join(M)\r\n\r\nM.execute() # peewee.OperationalError: (1066, \"Not unique table/alias: 't1'\")\r\n```\r\n\r\nIn fact, I always do the alias like your documentation [self-joins](http://peewee.readthedocs.io/en/latest/peewee/querying.html#self-joins)\r\n\r\n```\r\nMA = M.alias()\r\nquery = M.select().join(MA)\r\n\r\nquery.execute()\r\n```\r\n\r\nI think it is good enough, because if I want to specify other conditions, I can do that:\r\n\r\n```python\r\nM.select().join(MA).where(M.name == 'a', MA.name == 'b')\r\n```", "If you are doing a self-join you should always alias it (2nd example using `.join(MA)`).\r\n\r\nThe problem was that when using `.get()` with keyword-arguments, it is using the `.filter()` API under-the-hood, and this API does not cope well with self-referential FKs.\r\n\r\nThe standard APIs work just fine, however.", "I got it, thanks!" ]
2017-12-04T07:43:25
2017-12-06T00:27:41
2017-12-05T14:30:27
NONE
null
Please see this code: ```python import peewee db = peewee.MySQLDatabase(**CONNECT_KWARGS) class M(peewee.Model): parent= peewee.ForeignKeyField('self') class Meta: database= db db_table = 'M' M.get(parent=None) # It works. M.get(parent=10000) # It doesn't work. peewee.OperationalError: (1066, "Not unique table/alias: 't1'") ``` I've tested it both 2.10.2 and 3.0.a.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1396/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/1396/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1395
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1395/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1395/comments
https://api.github.com/repos/coleifer/peewee/issues/1395/events
https://github.com/coleifer/peewee/issues/1395
278,847,991
MDU6SXNzdWUyNzg4NDc5OTE=
1,395
ERROR:raysync:pysqlite or sqlite3 must be installed.
{ "login": "nuxwork", "id": 4026598, "node_id": "MDQ6VXNlcjQwMjY1OTg=", "avatar_url": "https://avatars.githubusercontent.com/u/4026598?v=4", "gravatar_id": "", "url": "https://api.github.com/users/nuxwork", "html_url": "https://github.com/nuxwork", "followers_url": "https://api.github.com/users/nuxwork/followers", "following_url": "https://api.github.com/users/nuxwork/following{/other_user}", "gists_url": "https://api.github.com/users/nuxwork/gists{/gist_id}", "starred_url": "https://api.github.com/users/nuxwork/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/nuxwork/subscriptions", "organizations_url": "https://api.github.com/users/nuxwork/orgs", "repos_url": "https://api.github.com/users/nuxwork/repos", "events_url": "https://api.github.com/users/nuxwork/events{/privacy}", "received_events_url": "https://api.github.com/users/nuxwork/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Try opening up a python shell and running:\r\n\r\n```\r\nfrom peewee import sqlite3\r\nprint sqlite3\r\n```\r\n\r\nYou can also try:\r\n\r\n```\r\nfrom pysqlite2 import dbapi2\r\nimport sqlite3\r\n```\r\n\r\nWhat happens?", "My python is compiled by myself, I forget to add sqlite3 module." ]
2017-12-04T01:58:39
2017-12-04T06:09:09
2017-12-04T06:09:09
NONE
null
The peewee i used , running ok on windows, but linux. it print `ERROR:pysqlite or sqlite3 must be installed.` ![20171204094931](https://user-images.githubusercontent.com/4026598/33532908-93616f10-d8d8-11e7-9339-a8a781e0f004.png) os: CentOS-x86_64-minimal python: Python 2.7.13 pip list: altgraph (0.14) backports-abc (0.5) certifi (2017.7.27.1) configparser (3.5.0) dis3 (0.1.1) future (0.16.0) hashids (1.2.0) macholib (1.8) peewee (2.10.2) pefile (2017.9.3) pip (9.0.1) protobuf (3.2.0) PyInstaller (3.3) pysqlite (2.8.3) setuptools (20.3.1) singledispatch (3.4.0.3) six (1.11.0) tornado (4.5.2)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1395/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/1395/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1394
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1394/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1394/comments
https://api.github.com/repos/coleifer/peewee/issues/1394/events
https://github.com/coleifer/peewee/issues/1394
278,680,969
MDU6SXNzdWUyNzg2ODA5Njk=
1,394
execute_sql pass typle to MySQLdb if param is None
{ "login": "daoiqi", "id": 2141872, "node_id": "MDQ6VXNlcjIxNDE4NzI=", "avatar_url": "https://avatars.githubusercontent.com/u/2141872?v=4", "gravatar_id": "", "url": "https://api.github.com/users/daoiqi", "html_url": "https://github.com/daoiqi", "followers_url": "https://api.github.com/users/daoiqi/followers", "following_url": "https://api.github.com/users/daoiqi/following{/other_user}", "gists_url": "https://api.github.com/users/daoiqi/gists{/gist_id}", "starred_url": "https://api.github.com/users/daoiqi/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/daoiqi/subscriptions", "organizations_url": "https://api.github.com/users/daoiqi/orgs", "repos_url": "https://api.github.com/users/daoiqi/repos", "events_url": "https://api.github.com/users/daoiqi/events{/privacy}", "received_events_url": "https://api.github.com/users/daoiqi/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "?", "MySQL\r\n\r\n```python\r\nsql = \"select DATE_FORMAT(MAX(NOW()),'%Y-%m-%d'); \"\r\nprint database.execute_sql(sql)\r\n\r\n\r\nsql = \"insert into t_user set name='abc%abc';\"\r\nprint database.execute_sql(sql)\r\n\r\n\r\n```\r\n```\r\nTraceback (most recent call last):\r\n File \"models.py\", line 1332, in <module>\r\n print database.execute_sql(sql)\r\n File \"/usr/lib/python2.6/site-packages/playhouse/shortcuts.py\", line 203, in execute_sql\r\n sql, params, require_commit)\r\n File \"/usr/lib/python2.6/site-packages/peewee.py\", line 3454, in execute_sql\r\n cursor.execute(sql, params or ())\r\n File \"/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py\", line 158, in execute\r\n query = query % db.literal(args)\r\nTypeError: not enough arguments for format string\r\n\r\n```\r\n\r\nhttps://github.com/coleifer/peewee/blob/c6b5946a997e39f9939b0261e2b75c46acbac8f2/peewee.py#L3831\r\n\r\n`params` is None", "Why aren't you parameterizing your query? You should use %s as the placeholder for those params, then pass them in as a tuple:\r\n\r\n```\r\ndb.execute_sql('select date_format(max(now)), %s)', ('%Y-%m-%d'))\r\n```" ]
2017-12-02T12:38:53
2017-12-06T12:52:25
2017-12-03T16:23:37
NONE
null
https://github.com/coleifer/peewee/blob/c6b5946a997e39f9939b0261e2b75c46acbac8f2/peewee.py#L3831 pass typle to MySQLdb if param is `None`, why not `None` to MySQLdb?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1394/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/1394/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1393
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1393/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1393/comments
https://api.github.com/repos/coleifer/peewee/issues/1393/events
https://github.com/coleifer/peewee/issues/1393
278,344,088
MDU6SXNzdWUyNzgzNDQwODg=
1,393
Problems with playhouse.db_url.connect objects when initialising database connection
{ "login": "andy47", "id": 782758, "node_id": "MDQ6VXNlcjc4Mjc1OA==", "avatar_url": "https://avatars.githubusercontent.com/u/782758?v=4", "gravatar_id": "", "url": "https://api.github.com/users/andy47", "html_url": "https://github.com/andy47", "followers_url": "https://api.github.com/users/andy47/followers", "following_url": "https://api.github.com/users/andy47/following{/other_user}", "gists_url": "https://api.github.com/users/andy47/gists{/gist_id}", "starred_url": "https://api.github.com/users/andy47/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/andy47/subscriptions", "organizations_url": "https://api.github.com/users/andy47/orgs", "repos_url": "https://api.github.com/users/andy47/repos", "events_url": "https://api.github.com/users/andy47/events{/privacy}", "received_events_url": "https://api.github.com/users/andy47/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You might try removing one of the slashes on the sqlite filename.\r\n\r\nIt seems a bit wonky to use `connect` to instantiate a db object, only to throw it away and call `init` on a different instance. I get that you want to use the logic in `connect()` -- but it seems like if you can do it in one place you should be able to do it in the other (e.g. in `models.py`).", "See also:\r\n\r\n* http://docs.peewee-orm.com/en/latest/peewee/database.html#run-time-database-configuration\r\n* http://docs.peewee-orm.com/en/latest/peewee/database.html#dynamically-defining-a-database", "Thanks for the response. How do I do this with a connection string? I'm working in an environment with different database backends on different machines - just Sqlite and PostgreSQL at the moment but I'd like to be able to use others in the future. How can I do this so that I don't have to parse the database config to work out which type of database object to create? \r\n\r\nUsing database URLs is perfect, as long as I can do lazy instantiation at run time.", "> OperationalError: FATAL: database \"/Users/andy47/my_db.sqlite\" does not exist\r\n\r\nWait a sec...is that error occurring because in your models you have `db = PostgresqlDatabase(None)`?", "Could have been, after your advice a couple of comments earlier I've changed this to a `Proxy()` object.", "I'm not sure why you have closed this, I still can't do a lazy instantiation of a database connection based on a connection string.", "```python\r\n\r\ndb = Proxy()\r\n\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = db\r\n\r\n# ... some time later ...\r\nreal_db = connect(connection_string)\r\ndb.initialize(real_db)\r\n```" ]
2017-12-01T03:10:28
2017-12-19T22:38:46
2017-12-19T21:18:00
NONE
null
I'm trying to dynamically initialise my database connection (at run time) using connection strings. This works fine with PostgreSQL ``` >>> from playhouse.db_url import connect >>> db = connect('postgres://user:password@localhost/database') >>> import models >>> models.db.init(db.database, **db.connect_kwargs) ``` Then any subsequent operations on the classes in the models module work fine. But if I try the same thing with a Sqlite connection string, e.g. ``` ... >>> db = connect('sqlite:////Users/andy47/my_db.sqlite') ... ``` Operations on the db object are fine (e.g. `execute_sql`) but when I use this in the `db.init` and then subsequently try and query a model class I get an error message; `OperationalError: FATAL: database "/Users/andy47/my_db.sqlite" does not exist` I note that the documentation (http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#db-url) only mentions databases in the current directory when discussing `sqlite` connection strings. But the connect works and provides a viable database connection. It's just when I use this to initialise my model database connection at run time that I get the error. I've got a question at StackOverflow talking about this as well - https://stackoverflow.com/questions/47273956/run-time-initialisation-of-peewee-database-for-different-database-backends
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1393/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/1393/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1392
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1392/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1392/comments
https://api.github.com/repos/coleifer/peewee/issues/1392/events
https://github.com/coleifer/peewee/issues/1392
277,293,409
MDU6SXNzdWUyNzcyOTM0MDk=
1,392
Cast json string as decimal, dates
{ "login": "aitchnyu", "id": 5927706, "node_id": "MDQ6VXNlcjU5Mjc3MDY=", "avatar_url": "https://avatars.githubusercontent.com/u/5927706?v=4", "gravatar_id": "", "url": "https://api.github.com/users/aitchnyu", "html_url": "https://github.com/aitchnyu", "followers_url": "https://api.github.com/users/aitchnyu/followers", "following_url": "https://api.github.com/users/aitchnyu/following{/other_user}", "gists_url": "https://api.github.com/users/aitchnyu/gists{/gist_id}", "starred_url": "https://api.github.com/users/aitchnyu/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/aitchnyu/subscriptions", "organizations_url": "https://api.github.com/users/aitchnyu/orgs", "repos_url": "https://api.github.com/users/aitchnyu/repos", "events_url": "https://api.github.com/users/aitchnyu/events{/privacy}", "received_events_url": "https://api.github.com/users/aitchnyu/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee 3.0a supports a `Cast` type and corresponding method.\r\n\r\n```python\r\n# untested, but should be about right\r\nquery = MyModel.select().where(Model.json['num'].cast('numeric') >= 100)\r\nprint query.count()\r\n```\r\n\r\nIn Peewee 2.x you can:\r\n\r\n```python\r\nfrom playhouse.shortcuts import cast\r\nquery = MyModel.select().where(cast(Model.json['num'], 'numeric') >= 100)\r\nprint query.count()\r\n```\r\n\r\nAnd yes, you can use these approaches for joining." ]
2017-11-28T08:14:00
2017-11-28T15:33:06
2017-11-28T15:33:05
NONE
null
In SQLAlchemy, I could do: ``` session\ .query(Model)\ .filter(Model.json['num'].astext.cast(db.Numeric) >= Decimal(100))\ .count() ``` I want to use the JSON field to store custom attributes in the form of decimal, dates and references to other objects (to do joins). Is there a similar cast method? Could I do joins with it?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1392/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/1392/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1391
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1391/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1391/comments
https://api.github.com/repos/coleifer/peewee/issues/1391/events
https://github.com/coleifer/peewee/issues/1391
275,763,157
MDU6SXNzdWUyNzU3NjMxNTc=
1,391
Question: is there a best practice changing schema configuration depending on the model used?
{ "login": "thxv3n0lvl", "id": 1503456, "node_id": "MDQ6VXNlcjE1MDM0NTY=", "avatar_url": "https://avatars.githubusercontent.com/u/1503456?v=4", "gravatar_id": "", "url": "https://api.github.com/users/thxv3n0lvl", "html_url": "https://github.com/thxv3n0lvl", "followers_url": "https://api.github.com/users/thxv3n0lvl/followers", "following_url": "https://api.github.com/users/thxv3n0lvl/following{/other_user}", "gists_url": "https://api.github.com/users/thxv3n0lvl/gists{/gist_id}", "starred_url": "https://api.github.com/users/thxv3n0lvl/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/thxv3n0lvl/subscriptions", "organizations_url": "https://api.github.com/users/thxv3n0lvl/orgs", "repos_url": "https://api.github.com/users/thxv3n0lvl/repos", "events_url": "https://api.github.com/users/thxv3n0lvl/events{/privacy}", "received_events_url": "https://api.github.com/users/thxv3n0lvl/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Could you be more specific?", "I just wanted to switch the schema using class Meta. I went through the docs and achieve it with this:\r\nhttp://docs.peewee-orm.com/en/latest/peewee/models.html#model-options-and-table-metadata" ]
2017-11-21T15:54:16
2017-11-24T22:25:52
2017-11-24T22:25:51
NONE
null
So I would like to know if there's a good way / approach to change schema configuration depending on the model used. I thought that `class Meta` was able to do that, but I can't find anything related to that on the docs, or probably not looking for it properly. Any advice? Best Regards!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1391/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/1391/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1390
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1390/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1390/comments
https://api.github.com/repos/coleifer/peewee/issues/1390/events
https://github.com/coleifer/peewee/issues/1390
275,568,963
MDU6SXNzdWUyNzU1Njg5NjM=
1,390
Inheritance with ForeignKeyFields
{ "login": "judemille", "id": 8127111, "node_id": "MDQ6VXNlcjgxMjcxMTE=", "avatar_url": "https://avatars.githubusercontent.com/u/8127111?v=4", "gravatar_id": "", "url": "https://api.github.com/users/judemille", "html_url": "https://github.com/judemille", "followers_url": "https://api.github.com/users/judemille/followers", "following_url": "https://api.github.com/users/judemille/following{/other_user}", "gists_url": "https://api.github.com/users/judemille/gists{/gist_id}", "starred_url": "https://api.github.com/users/judemille/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/judemille/subscriptions", "organizations_url": "https://api.github.com/users/judemille/orgs", "repos_url": "https://api.github.com/users/judemille/repos", "events_url": "https://api.github.com/users/judemille/events{/privacy}", "received_events_url": "https://api.github.com/users/judemille/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Can you provide an example? I'm not sure I follow about inheriting classes.", "You can disable backref validation by specifying:\r\n\r\n```python\r\nclass MyModel(Model):\r\n class Meta:\r\n validate_backrefs = False\r\n```\r\n\r\nAlso, so long as you aren't explicitly setting the `related_name`, inherited classes would dynamically set it based on the class name:\r\n\r\n```python\r\nclass Foo(Model): pass\r\n\r\nclass Bar(Model):\r\n foo = ForeignKeyField(Foo)\r\n\r\nclass Baz(Bar): pass\r\n\r\n# Foo.bar_set -> related Bar objects\r\n# Foo.baz_set -> related Baz objects\r\n```", "Is this your point?\r\n\r\n```python\r\n# common.py\r\nclass Foo(Model):\r\n pass\r\n\r\nclass Bar(Model):\r\n foo = ForeignKeyField(foo_proxy, related_name='bars')\r\n```\r\n\r\n```python\r\n# sub1.py\r\nclass Foo(common.Foo):\r\n pass\r\n\r\nclass Bar(common.Foo):\r\n pass\r\n```\r\n\r\n```python\r\n# sub2.py\r\nclass Foo(common.Foo):\r\n pass\r\n\r\nclass Bar(common.Bar):\r\n pass\r\n```\r\n", "@coleifer I want the inheriting classes and the base classes to share the same field in the foreign class so that they can all be grouped together. Is that possible? I'm not sure what the backref validation means", "I don't understand what \"foreign class\" means, or \"grouped together\" means?", "```python\r\nclass Foo(Model):\r\n pass\r\n\r\nclass Bar(Model):\r\n foothing = ForeignKeyField(Foo, related_name='bars')\r\n\r\nclass Baz(Bar):\r\n pass\r\n```\r\n\r\nI want both Bar and Baz to be in the bars field of Foo", "```python\r\nclass Foo(Model):\r\n @property\r\n def bars(self):\r\n return [] + self.bar_set + self.baz_set\r\n\r\nclass Bar(Model):\r\n foothing = ForeignKeyField(Foo)\r\n\r\nclass Baz(Bar):\r\n pass\r\n```", "@FireFaced -- that doesn't work how you think it might. `Bar` and `Baz` are two separate tables. The backref (`bars`) is a select query that is pre-filtered.\r\n\r\nSo, for example:\r\n\r\n```python\r\nf = Foo(id=1337)\r\nf.bars # SELECT * FROM bar WHERE foothing_id=1337\r\n```\r\n\r\nThus, a back-ref is limited to a single table. The example from @yanghg-basefx may work but is also inefficient in that it executes 2 queries and coerces to a list, potentially using a lot of memory if the result sets are large.", "So how could I implement it so that I can see all types of Bar? Would I end\nup using a different type of field or something?\n\nOn Mon, Nov 27, 2017, 10:34 Charles Leifer <[email protected]> wrote:\n\n> @FireFaced <https://github.com/firefaced> -- that doesn't work how you\n> think it might. Bar and Baz are two separate tables. The backref (bars)\n> is a select query that is pre-filtered.\n>\n> So, for example:\n>\n> f = Foo(id=1337)\n> f.bars # SELECT * FROM bar WHERE foothing_id=1337\n>\n> Thus, a back-ref is limited to a single table. The example from\n> @yanghg-basefx <https://github.com/yanghg-basefx> may work but is also\n> inefficient in that it executes 2 queries and coerces to a list,\n> potentially using a lot of memory if the result sets are large.\n>\n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/coleifer/peewee/issues/1390#issuecomment-347218717>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AHwCh-MaJFVflz_OCxRDlei_7sqMiNdjks5s6tZjgaJpZM4QlNgA>\n> .\n>\n", "Well the problem is that if you have two classes you'll end up with two separate tables. That makes sense, right? Depending on how you structure those tables, you could possibly use a UNION query or something, but you're quickly running into problems trying to conflate object-orientation with relational database design." ]
2017-11-21T02:55:46
2017-11-27T15:44:34
2017-11-27T15:33:50
NONE
null
When I try to inherit a class with a ForeignKeyField, I get an AttributeError about my related_name already being in use. I want all of the inheriting classes to share the same field in the foreign model so that they can be counted together. Is this possible?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1390/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/1390/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1389
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1389/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1389/comments
https://api.github.com/repos/coleifer/peewee/issues/1389/events
https://github.com/coleifer/peewee/pull/1389
274,811,269
MDExOlB1bGxSZXF1ZXN0MTUzMjU3MjE1
1,389
Do not force primary_key value on returning clause
{ "login": "gdraynz", "id": 5525902, "node_id": "MDQ6VXNlcjU1MjU5MDI=", "avatar_url": "https://avatars.githubusercontent.com/u/5525902?v=4", "gravatar_id": "", "url": "https://api.github.com/users/gdraynz", "html_url": "https://github.com/gdraynz", "followers_url": "https://api.github.com/users/gdraynz/followers", "following_url": "https://api.github.com/users/gdraynz/following{/other_user}", "gists_url": "https://api.github.com/users/gdraynz/gists{/gist_id}", "starred_url": "https://api.github.com/users/gdraynz/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/gdraynz/subscriptions", "organizations_url": "https://api.github.com/users/gdraynz/orgs", "repos_url": "https://api.github.com/users/gdraynz/repos", "events_url": "https://api.github.com/users/gdraynz/events{/privacy}", "received_events_url": "https://api.github.com/users/gdraynz/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Cheers, thanks!" ]
2017-11-17T10:00:57
2017-11-17T14:54:24
2017-11-17T14:54:20
CONTRIBUTOR
null
Using Postgresql, when calling `.returning(*)` on an `InsertQuery`, the `RETURNING` clause was always set to my single primary_key. I simply inverted the two possible returning clauses to ensure `.returning()` takes the priority.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1389/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/1389/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1389", "html_url": "https://github.com/coleifer/peewee/pull/1389", "diff_url": "https://github.com/coleifer/peewee/pull/1389.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1389.patch", "merged_at": "2017-11-17T14:54:20" }
https://api.github.com/repos/coleifer/peewee/issues/1388
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1388/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1388/comments
https://api.github.com/repos/coleifer/peewee/issues/1388/events
https://github.com/coleifer/peewee/issues/1388
274,682,733
MDU6SXNzdWUyNzQ2ODI3MzM=
1,388
Help wanted on querying
{ "login": "dashingspidy", "id": 4521441, "node_id": "MDQ6VXNlcjQ1MjE0NDE=", "avatar_url": "https://avatars.githubusercontent.com/u/4521441?v=4", "gravatar_id": "", "url": "https://api.github.com/users/dashingspidy", "html_url": "https://github.com/dashingspidy", "followers_url": "https://api.github.com/users/dashingspidy/followers", "following_url": "https://api.github.com/users/dashingspidy/following{/other_user}", "gists_url": "https://api.github.com/users/dashingspidy/gists{/gist_id}", "starred_url": "https://api.github.com/users/dashingspidy/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/dashingspidy/subscriptions", "organizations_url": "https://api.github.com/users/dashingspidy/orgs", "repos_url": "https://api.github.com/users/dashingspidy/repos", "events_url": "https://api.github.com/users/dashingspidy/events{/privacy}", "received_events_url": "https://api.github.com/users/dashingspidy/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This kind of question is not appropriate for the issue tracker. Please post to stackoverflow.\r\n\r\nBecause I'm a nice guy :) you're getting duplicate rows because you're joining on Photo...why are you joining on photo in the above query?" ]
2017-11-16T22:13:49
2017-11-16T22:46:23
2017-11-16T22:46:23
NONE
null
I have User and Photo table and when i join them while querying, it duplicates User based on how many photo is associated with. ``` class User(BaseModel): id = PrimaryKeyField() looking_for = CharField() ``` ``` class Photo(BaseModel): id = PrimaryKeyField() url = CharField() user = ForeignKeyField(User, related_name='photos') ``` Query: `User.select(User, Photo).join(Photo).where(User.looking_for == 'params')`
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1388/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/1388/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1387
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1387/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1387/comments
https://api.github.com/repos/coleifer/peewee/issues/1387/events
https://github.com/coleifer/peewee/pull/1387
274,308,776
MDExOlB1bGxSZXF1ZXN0MTUyODg4NDU4
1,387
doc: Fix a typo
{ "login": "bfontaine", "id": 1334295, "node_id": "MDQ6VXNlcjEzMzQyOTU=", "avatar_url": "https://avatars.githubusercontent.com/u/1334295?v=4", "gravatar_id": "", "url": "https://api.github.com/users/bfontaine", "html_url": "https://github.com/bfontaine", "followers_url": "https://api.github.com/users/bfontaine/followers", "following_url": "https://api.github.com/users/bfontaine/following{/other_user}", "gists_url": "https://api.github.com/users/bfontaine/gists{/gist_id}", "starred_url": "https://api.github.com/users/bfontaine/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/bfontaine/subscriptions", "organizations_url": "https://api.github.com/users/bfontaine/orgs", "repos_url": "https://api.github.com/users/bfontaine/repos", "events_url": "https://api.github.com/users/bfontaine/events{/privacy}", "received_events_url": "https://api.github.com/users/bfontaine/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-11-15T21:21:57
2017-11-19T16:42:35
2017-11-15T22:20:32
CONTRIBUTOR
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1387/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/1387/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1387", "html_url": "https://github.com/coleifer/peewee/pull/1387", "diff_url": "https://github.com/coleifer/peewee/pull/1387.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1387.patch", "merged_at": "2017-11-15T22:20:32" }
https://api.github.com/repos/coleifer/peewee/issues/1386
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1386/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1386/comments
https://api.github.com/repos/coleifer/peewee/issues/1386/events
https://github.com/coleifer/peewee/issues/1386
274,259,568
MDU6SXNzdWUyNzQyNTk1Njg=
1,386
create_tables(...,safe=True) fails after migration unless Meta.db_table is defined on model
{ "login": "aurcioli-handy", "id": 15836389, "node_id": "MDQ6VXNlcjE1ODM2Mzg5", "avatar_url": "https://avatars.githubusercontent.com/u/15836389?v=4", "gravatar_id": "", "url": "https://api.github.com/users/aurcioli-handy", "html_url": "https://github.com/aurcioli-handy", "followers_url": "https://api.github.com/users/aurcioli-handy/followers", "following_url": "https://api.github.com/users/aurcioli-handy/following{/other_user}", "gists_url": "https://api.github.com/users/aurcioli-handy/gists{/gist_id}", "starred_url": "https://api.github.com/users/aurcioli-handy/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/aurcioli-handy/subscriptions", "organizations_url": "https://api.github.com/users/aurcioli-handy/orgs", "repos_url": "https://api.github.com/users/aurcioli-handy/repos", "events_url": "https://api.github.com/users/aurcioli-handy/events{/privacy}", "received_events_url": "https://api.github.com/users/aurcioli-handy/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm confused... Peewee normalizes the case of the table name from the model name in the absence of an explicit `db_table`, so the first call to create_tables() in step 1 should be using the same table name as in step 3.", "This is odd, it appears to be changing the case unpredictably.\r\n\r\nHere is what I am seeing:\r\n\r\nthis is my model (note i am forcing it to downcase on this example)\r\nAt each step I will show the output of `cls._meta.db_table` and `cls._meta.database.get_tables`\r\n\r\n### 1. Initial create_tables (table does not yet exist)\r\n```python\r\nclass KubernetesUser(BaseModel):\r\n ldap_username = TextField()\r\n token = TextField()\r\n uid = TextField()\r\n created_at = DateTimeField()\r\n\r\n class Meta:\r\n db_table = 'kubernetesuser'\r\n```\r\n\r\nI run `create_tables([KubernetesUser], safe=True)`\r\nTable created successfully:\r\n`cls._meta.db_table` = kubernetesuser\r\n`cls._meta.database.get_tables` = []\r\n\r\n### 2. Run create_tables again to show output and verify its working as expected\r\n```python\r\ncreate_tables([KubernetesUser], safe=True)\r\n```\r\n\r\n`cls._meta.db_table` = kubernetesuser\r\n`cls._meta.database.get_tables` = ['kubernetesuser']\r\n\r\n### 3. Run a migration to add a column\r\n```python\r\nmigrate(\r\n migrator.add_column('KubernetesUser', 'token_updated_at', token_updated_at_field)\r\n )\r\n```\r\nColumn is successfully added\r\n\r\n### 4. Run create_tables again\r\n```python\r\ncreate_tables([KubernetesUser], safe=True)\r\n```\r\n\r\n`cls._meta.db_table` = kubernetesuser\r\n`cls._meta.database.get_tables` = ['KubernetesUser']\r\n\r\n***pymysql.err.InternalError: (1050, \"Table 'kubernetesuser' already exists\")***\r\n\r\nIs it the migration causing the table name to be changed?\r\n\r\n", "Yep that seems to be it - the migration is changing the case and the code is always expecting lowercase.. \r\n\r\nbefore migration:\r\nmysql> show tables;\r\n+--------------------------+\r\n| Tables_in_kube_ldap_auth |\r\n+--------------------------+\r\n| kubernetesuser |\r\n+--------------------------+\r\n\r\nafter migration:\r\n+--------------------------+\r\n| Tables_in_kube_ldap_auth |\r\n+--------------------------+\r\n| KubernetesUser |\r\n+--------------------------+\r\n\r\nseems its my fault then for adding case to the table name in the migration.\r\n\r\nKnowing that peewee normalizes the name to lowercase, perhaps the migration code should force lowercase on the table name for migrations to avoid users shooting themselves in the foot like I have.", "Yeah in your migration you need to specify the table name using the same case as the model name. \"kubernetesuser\". That ought to fix ya." ]
2017-11-15T18:32:53
2017-11-15T19:21:47
2017-11-15T19:21:47
NONE
null
**Expected behavior:** create_tables([MyModel], safe=True) does not raise an error if table exists **Observed behavior:** `peewee.InternalError: (1050, "Table 'MyModel' already exists")` **How to reproduce** 1. Create a simple model definition and run create_tables() 2. Create and run a migration to add a column to the table 3. Run create_tables(...,safe=True) **Problem** `table_exists()` method checks if cls._meta.db_table is contained in cls._meta.database.get_tables`, however cls._meta.db_table returns an all lowercase string name, while cls._meta.database.get_tables respects the case on the model. ```python mymodel in ['MyModel'] ``` fails as expected **Fix:** To mitigate this issue i've added the following code to my model ```python class MyModel(BaseModel): foo = TextField() class Meta: db_table = 'MyModel' ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1386/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/1386/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1385
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1385/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1385/comments
https://api.github.com/repos/coleifer/peewee/issues/1385/events
https://github.com/coleifer/peewee/issues/1385
274,258,935
MDU6SXNzdWUyNzQyNTg5MzU=
1,385
KeyError when fields specified in select()
{ "login": "jspayne", "id": 4028489, "node_id": "MDQ6VXNlcjQwMjg0ODk=", "avatar_url": "https://avatars.githubusercontent.com/u/4028489?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jspayne", "html_url": "https://github.com/jspayne", "followers_url": "https://api.github.com/users/jspayne/followers", "following_url": "https://api.github.com/users/jspayne/following{/other_user}", "gists_url": "https://api.github.com/users/jspayne/gists{/gist_id}", "starred_url": "https://api.github.com/users/jspayne/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jspayne/subscriptions", "organizations_url": "https://api.github.com/users/jspayne/orgs", "repos_url": "https://api.github.com/users/jspayne/repos", "events_url": "https://api.github.com/users/jspayne/events{/privacy}", "received_events_url": "https://api.github.com/users/jspayne/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The issue is you're selecting a column on a joined model, but not selecting anything from Test_File_Options.\r\n\r\nYou probably want to rewrite as:\r\n\r\n```python\r\n(TestFile\r\n .select(TestFile.filename)\r\n .join(Test_File_Options)\r\n .join(TestOption)\r\n .where(TestOption.option == '-G')\r\n .get())\r\n```" ]
2017-11-15T18:30:29
2017-11-15T18:45:10
2017-11-15T18:45:10
NONE
null
Test_File_Options is a many-many foreign key table with references to TestFile and TestOptions. ``` q1 = Test_File_Options.select(TestFile.file_name).join(TestFile).switch(Test_File_Options).join(TestOption).where(TestOption.option == '-G').distinct().alias('q1a') ``` I can directly run the query generated by the above, and get what I'd expect. q1.get() results in `KeyError: <class 'compile_opts_db_mysql.Test_File_Options'>` If I remove the `TestFile.file_name` from the select(), there is no error [I'm trying to select the field here because later I'm trying to join q1 to a q2 with a different option based on file_name, and need to specify the join field]
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1385/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/1385/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1384
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1384/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1384/comments
https://api.github.com/repos/coleifer/peewee/issues/1384/events
https://github.com/coleifer/peewee/issues/1384
274,238,189
MDU6SXNzdWUyNzQyMzgxODk=
1,384
Massive overhead when iterating over 1k+ rows in postgres even with server side cursors
{ "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
[ "My sense is that this has to do with using server-side cursors, but I couldn't be more specific. A further consideration is that when you iterate over a large list of rows, Peewee will cache the results in memory to make subsequent iterations fast. If you only need to do a single-pass, you can add \".iterator()\" to your query:\r\n\r\n```python\r\ndef run_peewee_query():\r\n query = PeeweePerson.select(PeeweePerson.id).order_by(PeeweePerson.id.desc()).limit(limit)\r\n ids = list(query.iterator().tuples())\r\n return ids\r\n```\r\n\r\nIt's possible that SQLAlchemy may be calling `fetchmany()` or `fetchall()`? I'm not really sure. If the time is being spent in `cursor.fetchone()` then that tells me that any processing in Peewee itself is probably not the cause of the slowness. It might simply be the way peewee is handling the cursor?", "Leaving link to psycopg2 docs for handy reference: http://initd.org/psycopg/docs/usage.html#server-side-cursors", "I tried the iterator (fixed to `list(query.tuples().iterator())`) but found no improvement.\r\n\r\nAs far as I can tell you're right - the cursor is not being handled correctly. I'll continue digging into this.\r\n\r\nFYI also asked this on SO. Ref: https://stackoverflow.com/q/47313869/2533895", "How's the performance when using client-side cursors?", "@coleifer Ok, performance with client-side cursors is great - i should've tried that in the first place.\r\n\r\nDefinitely a bug with the server-side cursor implementation.", "I found this issue, too. I try to use this solution in our company:\r\n\r\n```python\r\nclass QueryResultCursor(object):\r\n def __init__(self, cursor):\r\n super(QueryResultCursor, self).__init__()\r\n self.rows = cursor.fetchall()\r\n self.row_iterator = iter(self.rows)\r\n self.close = cursor.close\r\n self.description = cursor.descrition\r\n self.name = getattr(cursor, 'name', None)\r\n\r\n def fetchone(self):\r\n try:\r\n return self.row_iterator.next()\r\n except StopIteration:\r\n return None\r\n\r\nclass QueryResultWrapper(object):\r\n def __init__(self, model, cursor, meta=None):\r\n self.cursor = QueryResultCursor(cursor)\r\n ...\r\n```\r\n\r\nYes, actually this will fetch all rows at once to memory, and I don't need to change your code any more :)", "But you are right, don't use server-side cursors is a better choice", "I'll see about fixing this for 3.0a.", "@ParthGandhi -- out of curiosity, what version of psycopg2 are you using?", "If you're interested, you might want to try out the latest commit in the 3.0a branch, which has a rewritten server-side implementation: 0ae17c519475c935d9db3c338f36ef058a3f879c", "`psycopg2==2.7.3.2`\r\n\r\nOooh, thanks. Will check that out.", "How'd things go with the new implementation?", "Haven't had a chance to try it out yet - got pulled into other work." ]
2017-11-15T17:21:30
2017-11-29T20:17:38
2017-11-29T20:17:38
NONE
null
I'm seeing an inexplicably large overhead when iterating over a postgres table. I profiled the code, and also did a smoke test with `SQLAlchemy` to make sure it wasn't a slow connection or the underlying driver (`psycopg2`). Running this against a postgres table of ~1M records but fetching only a tiny fraction of that. ```python import time import peewee import sqlalchemy from playhouse import postgres_ext from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.engine.url import URL as AlchemyURL from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker as alchemy_sessionmaker user = 'XXX' password = 'XXX' database = 'XXX' host = 'XXX' port = 5432 table = 'person' limit = 1000 peewee_db = postgres_ext.PostgresqlExtDatabase( database=database, host=host, port=port, user=user, password=password, use_speedups=True, server_side_cursors=True, register_hstore=False, ) alchemy_engine = sqlalchemy.create_engine(AlchemyURL('postgresql', username=user, password=password, database=database, host=host, port=port)) alchemy_session = alchemy_sessionmaker(bind=alchemy_engine)() class PeeweePerson(peewee.Model): class Meta: database = peewee_db db_table = table id = peewee.CharField(primary_key=True, max_length=64) data = postgres_ext.BinaryJSONField(index=True, index_type='GIN') class SQLAlchemyPerson(declarative_base()): __tablename__ = table id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) data = sqlalchemy.Column(JSONB) def run_raw_query(): ids = list(peewee_db.execute_sql(f"SELECT id from {table} order by id desc limit {limit}")) return ids def run_peewee_query(): query = PeeweePerson.select(PeeweePerson.id).order_by(PeeweePerson.id.desc()).limit(limit) ids = list(query.tuples()) return ids def run_sqlalchemy_query(): query = alchemy_session.query(SQLAlchemyPerson.id).order_by(sqlalchemy.desc(SQLAlchemyPerson.id)).limit(limit) ids = list(query) return ids if __name__ == '__main__': t0 = time.time() raw_result = run_raw_query() t1 = time.time() print(f'Raw: {t1 - t0}') t2 = time.time() sqlalchemy_result = run_sqlalchemy_query() t3 = time.time() print(f'SQLAlchemy: {t3 - t2}') t4 = time.time() peewee_result = run_peewee_query() t5 = time.time() print(f'peewee: {t5 - t4}') assert raw_result == sqlalchemy_result == peewee_result ``` #### Outputs - With `limit = 1000`: ``` Raw: 0.02643609046936035 SQLAlchemy: 0.03697466850280762 peewee: 1.0509874820709229 ``` - With `limit = 10000` ``` Raw: 0.15931344032287598 SQLAlchemy: 0.07229042053222656 peewee: 10.82826042175293 ``` Both examples use server side cursors. I briefly profiled this, and looks like 95%+ of the time is spent calling `cursor.fetchone` https://github.com/coleifer/peewee/blob/d8e34b0682d87bd56c1a3636445d9c0fccf2b1e2/peewee.py#L2340 I'll continue profiling this, but was wondering if you knew what was up?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1384/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/1384/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1383
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1383/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1383/comments
https://api.github.com/repos/coleifer/peewee/issues/1383/events
https://github.com/coleifer/peewee/issues/1383
273,613,980
MDU6SXNzdWUyNzM2MTM5ODA=
1,383
Executing multiple statements in one raw query gives Commands out of sync
{ "login": "nuclearspike", "id": 1151638, "node_id": "MDQ6VXNlcjExNTE2Mzg=", "avatar_url": "https://avatars.githubusercontent.com/u/1151638?v=4", "gravatar_id": "", "url": "https://api.github.com/users/nuclearspike", "html_url": "https://github.com/nuclearspike", "followers_url": "https://api.github.com/users/nuclearspike/followers", "following_url": "https://api.github.com/users/nuclearspike/following{/other_user}", "gists_url": "https://api.github.com/users/nuclearspike/gists{/gist_id}", "starred_url": "https://api.github.com/users/nuclearspike/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/nuclearspike/subscriptions", "organizations_url": "https://api.github.com/users/nuclearspike/orgs", "repos_url": "https://api.github.com/users/nuclearspike/repos", "events_url": "https://api.github.com/users/nuclearspike/events{/privacy}", "received_events_url": "https://api.github.com/users/nuclearspike/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Nevermind. I fixed it by running it in one transaction as two separate .raw() queries." ]
2017-11-13T23:22:59
2017-11-14T01:00:45
2017-11-14T01:00:45
NONE
null
How do I run a query that has two statements that must be run together? ``` tr = TensorRaw.raw(""" SET @x := 0; SELECT * FROM (SELECT (@x:=@x+1) AS x, mt.* FROM tensor_raw mt ORDER BY servertime desc) t WHERE MOD(x, 5) = 0 limit 100; """).execute() ``` This throws: peewee.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") I tried running them in one transaction but the second query returns no results that way.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1383/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/1383/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1382
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1382/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1382/comments
https://api.github.com/repos/coleifer/peewee/issues/1382/events
https://github.com/coleifer/peewee/issues/1382
273,584,576
MDU6SXNzdWUyNzM1ODQ1NzY=
1,382
sqliteq: method is not supported during get_or_create
{ "login": "gsemet", "id": 133498, "node_id": "MDQ6VXNlcjEzMzQ5OA==", "avatar_url": "https://avatars.githubusercontent.com/u/133498?v=4", "gravatar_id": "", "url": "https://api.github.com/users/gsemet", "html_url": "https://github.com/gsemet", "followers_url": "https://api.github.com/users/gsemet/followers", "following_url": "https://api.github.com/users/gsemet/following{/other_user}", "gists_url": "https://api.github.com/users/gsemet/gists{/gist_id}", "starred_url": "https://api.github.com/users/gsemet/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/gsemet/subscriptions", "organizations_url": "https://api.github.com/users/gsemet/orgs", "repos_url": "https://api.github.com/users/gsemet/repos", "events_url": "https://api.github.com/users/gsemet/events{/privacy}", "received_events_url": "https://api.github.com/users/gsemet/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Correct. The docs state this:\r\n\r\n> The downside, however, is that you cannot issue write transactions that encompass multiple queries – all writes run in autocommit mode, essentially.\r\n\r\nTo prevent users from shooting themselves in the foot, transaction APIs are disabled.\r\n\r\nThe problem is you're mixing two paradigms for multi-threaded database access. SqliteQ is only suitable for certain classes of problem...specifically, those where writes can be issued in autocommit mode. To do get-or-create you really need a multi-statement transaction... something like SELECT ... FOR UPDATE, which Sqlite doesn't support. It *does* however support the non-standard INSERT OR REPLACE query, which is perfect for get-or-create, as long as you have a constraint in place.\r\n\r\nSo I'd suggest changing your get-or-create to an INSERT OR REPLACE query, enforced by a constraint. Or alternatively do not use SqliteQ.", "ok. Which sqlite engine should I use with my asyncio program (only event loop access to the sqlite file)?", "Oh brother... asyncio is a garbage fire. I have no idea, but definitely not sqliteq.", "why so ?\r\n" ]
2017-11-13T21:30:12
2017-11-14T16:40:46
2017-11-14T15:41:45
NONE
null
`get_or_create` raises an exception when the row does not exist when using sqliteq ``` except cls.DoesNotExist: try: params = dict((k, v) for k, v in kwargs.items() if '__' not in k) params.update(defaults) with cls._meta.database.atomic(): return cls.create(**params), True ``` The `cls._meta.database.atomic()` cannot works, because we have in `sqlite.py`: ``` atomic = transaction = savepoint = __unsupported__ ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1382/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/1382/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1381
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1381/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1381/comments
https://api.github.com/repos/coleifer/peewee/issues/1381/events
https://github.com/coleifer/peewee/issues/1381
273,425,594
MDU6SXNzdWUyNzM0MjU1OTQ=
1,381
Provide an enumeration for valid on_delete values.
{ "login": "conqp", "id": 3766192, "node_id": "MDQ6VXNlcjM3NjYxOTI=", "avatar_url": "https://avatars.githubusercontent.com/u/3766192?v=4", "gravatar_id": "", "url": "https://api.github.com/users/conqp", "html_url": "https://github.com/conqp", "followers_url": "https://api.github.com/users/conqp/followers", "following_url": "https://api.github.com/users/conqp/following{/other_user}", "gists_url": "https://api.github.com/users/conqp/gists{/gist_id}", "starred_url": "https://api.github.com/users/conqp/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/conqp/subscriptions", "organizations_url": "https://api.github.com/users/conqp/orgs", "repos_url": "https://api.github.com/users/conqp/repos", "events_url": "https://api.github.com/users/conqp/events{/privacy}", "received_events_url": "https://api.github.com/users/conqp/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Enum is a python 3 thing, using it in 2.x requires a separate library if I'm not mistaken. Similarly, I prefer not to hard-code the list of supported actions since there may be some variance between options between databases (?)." ]
2017-11-13T13:15:57
2017-11-13T14:42:28
2017-11-13T14:42:28
CONTRIBUTOR
null
Currently, the `on_delete` keyword argument of `ForeignKeyField` takes arbitrary strings. The valid values are not documented in the [API reference](http://docs.peewee-orm.com/en/latest/peewee/api.html?highlight=cascade#ForeignKeyField) - just one example is given. Assuming that all [options supported by MySQL](https://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html) work, I request adding the following `enum.Enum` to peewee to be used alternatively to provide the field with the respective option. ``` class ForeignKeyConstraint(Enum): """Valid constraints for ForeignKeyFields.""" RESTRICT = 'RESTRICT' CASCADE = 'CASCADE' SET_NULL = 'SET NULL' NO_ACTION = 'NO ACTION' SET_DEFAULT = 'SET DEFAULT' def __str__(self): return self.value ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1381/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/1381/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1380
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1380/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1380/comments
https://api.github.com/repos/coleifer/peewee/issues/1380/events
https://github.com/coleifer/peewee/issues/1380
273,038,741
MDU6SXNzdWUyNzMwMzg3NDE=
1,380
get_or_create causes duplicates with multiprocessing
{ "login": "jspayne", "id": 4028489, "node_id": "MDQ6VXNlcjQwMjg0ODk=", "avatar_url": "https://avatars.githubusercontent.com/u/4028489?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jspayne", "html_url": "https://github.com/jspayne", "followers_url": "https://api.github.com/users/jspayne/followers", "following_url": "https://api.github.com/users/jspayne/following{/other_user}", "gists_url": "https://api.github.com/users/jspayne/gists{/gist_id}", "starred_url": "https://api.github.com/users/jspayne/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jspayne/subscriptions", "organizations_url": "https://api.github.com/users/jspayne/orgs", "repos_url": "https://api.github.com/users/jspayne/repos", "events_url": "https://api.github.com/users/jspayne/events{/privacy}", "received_events_url": "https://api.github.com/users/jspayne/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "`get_or_create()` is not a silver bullet...race conditions abound.\r\n\r\nYour best bet is to use database constraints (as you are) and do something like select for update or create->get.\r\n\r\n```python\r\nwith db.atomic():\r\n try:\r\n test_file = TestFile.select().where(TestFile.filename == f).for_update().get()\r\n except TestFile.DoesNotExist:\r\n TestFile.create(filename=f)\r\n```\r\n\r\nOr, better, since it seems you'd rather create them:\r\n\r\n```python\r\ntry:\r\n with db.atomic():\r\n TestFile.create(filename=f)\r\nexcept IntegrityError:\r\n pass\r\n```", "Ok, good to know. I went with the latter solution and it seems to be working. Thanks!" ]
2017-11-10T19:43:58
2017-11-13T17:10:56
2017-11-13T17:10:56
NONE
null
Name: peewee Version: 2.10.2 I've tried implementing multiprocessing with peewee in two different ways. Example 1: ``` import peewee as pw from playhouse.pool import PooledMySQLDatabase import multiprocessing as mp db = PooledMySQLDatabase("options_db", threadlocals=True, user="opts_user", passwd="opts_pass", max_connections=10) def main(): with db.execution_context(): db.create_tables([TestFile], safe=True) set1 = ['foo', 'bar', 'baz', 'bun'] set2 = ['foo', 'bar', 'bun', 'bog', 'buz', 'baz'] data = [set1, set2, set1, set2, set1, set1] p = mp.Pool(mp.cpu_count()) # The map creates a list of Counters, one for each result file p.map(worker, data) def worker(files): for f in files: with db.execution_context(): TestFile.get_or_create(file_name=f) class TestFile(pw.Model): file_name = pw.CharField(unique=True, index=True) class Meta: database = db if __name__ == "__main__": main() ``` Example 2: ``` import peewee as pw import multiprocessing as mp db = pw.Proxy() def main(): main_db = pw.MySQLDatabase("options_db", threadlocals=True, user="opts_user", passwd="opts_pass") db.initialize(main_db) db.connect() db.create_tables([TestFile], safe=True) db.close() set1 = ['foo', 'bar', 'baz', 'bun'] set2 = ['foo', 'bar', 'bun', 'bog', 'buz', 'baz'] data = [set1, set2, set1, set2, set1, set1] p = mp.Pool(mp.cpu_count()) # The map creates a list of Counters, one for each result file p.map(worker, data) def worker(files): worker_db = pw.MySQLDatabase("options_db", threadlocals=True, user="opts_user", passwd="opts_pass") db.initialize(worker_db) for f in files: with db.atomic(): TestFile.get_or_create(file_name=f) class TestFile(pw.Model): file_name = pw.CharField(unique=True, index=True) class Meta: database = db if __name__ == "__main__": main() ``` I can see how the first might not work because of the object cloning magic that happens with multiprocessing. But in the second case, each process should have its own connection to the DB, and have its own local data, no? In both cases I get exceptions due to duplicate entries even though I'm using get_or_create (`peewee.IntegrityError: (1062, "Duplicate entry 'bog' for key 'testfile_file_name'")`). I also sometimes get `TestFileDoesNotExist: Instance matching query does not exist: SQL` or save point does not exist errors. Thoughts?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1380/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/1380/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1379
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1379/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1379/comments
https://api.github.com/repos/coleifer/peewee/issues/1379/events
https://github.com/coleifer/peewee/pull/1379
271,823,839
MDExOlB1bGxSZXF1ZXN0MTUxMTA3NTc0
1,379
Fix Postgres extension's full text search Match
{ "login": "lerry", "id": 1225368, "node_id": "MDQ6VXNlcjEyMjUzNjg=", "avatar_url": "https://avatars.githubusercontent.com/u/1225368?v=4", "gravatar_id": "", "url": "https://api.github.com/users/lerry", "html_url": "https://github.com/lerry", "followers_url": "https://api.github.com/users/lerry/followers", "following_url": "https://api.github.com/users/lerry/following{/other_user}", "gists_url": "https://api.github.com/users/lerry/gists{/gist_id}", "starred_url": "https://api.github.com/users/lerry/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/lerry/subscriptions", "organizations_url": "https://api.github.com/users/lerry/orgs", "repos_url": "https://api.github.com/users/lerry/repos", "events_url": "https://api.github.com/users/lerry/events{/privacy}", "received_events_url": "https://api.github.com/users/lerry/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-11-07T13:03:16
2017-11-07T15:32:00
2017-11-07T15:32:00
NONE
null
the field should also be converted to to_tsvector with language
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1379/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/1379/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1379", "html_url": "https://github.com/coleifer/peewee/pull/1379", "diff_url": "https://github.com/coleifer/peewee/pull/1379.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1379.patch", "merged_at": "2017-11-07T15:32:00" }
https://api.github.com/repos/coleifer/peewee/issues/1378
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1378/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1378/comments
https://api.github.com/repos/coleifer/peewee/issues/1378/events
https://github.com/coleifer/peewee/issues/1378
271,765,141
MDU6SXNzdWUyNzE3NjUxNDE=
1,378
Setting MySQL storage engine
{ "login": "tomvlk", "id": 3877688, "node_id": "MDQ6VXNlcjM4Nzc2ODg=", "avatar_url": "https://avatars.githubusercontent.com/u/3877688?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tomvlk", "html_url": "https://github.com/tomvlk", "followers_url": "https://api.github.com/users/tomvlk/followers", "following_url": "https://api.github.com/users/tomvlk/following{/other_user}", "gists_url": "https://api.github.com/users/tomvlk/gists{/gist_id}", "starred_url": "https://api.github.com/users/tomvlk/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tomvlk/subscriptions", "organizations_url": "https://api.github.com/users/tomvlk/orgs", "repos_url": "https://api.github.com/users/tomvlk/repos", "events_url": "https://api.github.com/users/tomvlk/events{/privacy}", "received_events_url": "https://api.github.com/users/tomvlk/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "https://github.com/coleifer/peewee/issues/178#issuecomment-232955141" ]
2017-11-07T09:38:14
2017-11-15T17:37:27
2017-11-15T17:37:27
NONE
null
I wonder if it's already possible to set the MySQL storage engine for tables in a model or anywhere so it kinda works with ``create_tables`` method. I ask this because of the limitation when the default storage engine is set to MyISAM and when you are creating tables in a utf8mb4_unicode_ci collation, it will complain about varchar indexes over the limit. I have to advice users to change their default storage engine right now, but it would be better to just create the tables with the storage engine given as a parameter.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1378/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/1378/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1377
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1377/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1377/comments
https://api.github.com/repos/coleifer/peewee/issues/1377/events
https://github.com/coleifer/peewee/issues/1377
271,499,114
MDU6SXNzdWUyNzE0OTkxMTQ=
1,377
prevent related attribute assignement
{ "login": "scilo7", "id": 2485641, "node_id": "MDQ6VXNlcjI0ODU2NDE=", "avatar_url": "https://avatars.githubusercontent.com/u/2485641?v=4", "gravatar_id": "", "url": "https://api.github.com/users/scilo7", "html_url": "https://github.com/scilo7", "followers_url": "https://api.github.com/users/scilo7/followers", "following_url": "https://api.github.com/users/scilo7/following{/other_user}", "gists_url": "https://api.github.com/users/scilo7/gists{/gist_id}", "starred_url": "https://api.github.com/users/scilo7/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/scilo7/subscriptions", "organizations_url": "https://api.github.com/users/scilo7/orgs", "repos_url": "https://api.github.com/users/scilo7/repos", "events_url": "https://api.github.com/users/scilo7/events{/privacy}", "received_events_url": "https://api.github.com/users/scilo7/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "This isn't SQLAlchemy, home-skillet!\r\n\r\nGood suggestion on making read-only :+1: ", "So, I just prototyped the change and realized I can't enforce making back-references read-only because under some conditions, when resolving a query, Peewee may assign a list to the backref. For example when calling `dict_to_model`, it's possible to end up assigning a list to the back-reference. Similar goes for `prefetch`." ]
2017-11-06T14:45:03
2017-11-06T15:13:33
2017-11-06T15:13:33
NONE
null
Coming from sqlalchemy, it's not obvious that related attributes shouldn't be assigned. ```python class User(Model): name = CharField() class Tweet(Model): text = CharField() user = ForeignKeyField(User, null=True, related_name='tweets') u = User(name='bob') u.save() u.tweets = [Tweet(text='baaa'), Tweet(text='boo')] # does not work at all ``` With this code, u.tweets is mutated from peewee.SelectQuery to a list. Could the related attribute ("tweets") be handeled as a readonly property to prevent this ?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1377/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/1377/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1376
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1376/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1376/comments
https://api.github.com/repos/coleifer/peewee/issues/1376/events
https://github.com/coleifer/peewee/issues/1376
271,334,490
MDU6SXNzdWUyNzEzMzQ0OTA=
1,376
soundex postgres
{ "login": "ra-esmith", "id": 24212262, "node_id": "MDQ6VXNlcjI0MjEyMjYy", "avatar_url": "https://avatars.githubusercontent.com/u/24212262?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ra-esmith", "html_url": "https://github.com/ra-esmith", "followers_url": "https://api.github.com/users/ra-esmith/followers", "following_url": "https://api.github.com/users/ra-esmith/following{/other_user}", "gists_url": "https://api.github.com/users/ra-esmith/gists{/gist_id}", "starred_url": "https://api.github.com/users/ra-esmith/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ra-esmith/subscriptions", "organizations_url": "https://api.github.com/users/ra-esmith/orgs", "repos_url": "https://api.github.com/users/ra-esmith/repos", "events_url": "https://api.github.com/users/ra-esmith/events{/privacy}", "received_events_url": "https://api.github.com/users/ra-esmith/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm not sure exactly what you mean, but Peewee supports arbitrary function calls:\r\n\r\n```\r\nSomeModel.select().where(fn.soundex(SomeModel.column) == fn.soundex(search_string))\r\n```" ]
2017-11-06T01:25:23
2017-11-06T15:09:14
2017-11-06T15:09:14
NONE
null
Hello, Rather than use contains in my where clause I would like to use postgres soundex. Does peewee support soundex? What would be an example of the syntax. Thanks, Evan
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1376/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/1376/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1375
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1375/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1375/comments
https://api.github.com/repos/coleifer/peewee/issues/1375/events
https://github.com/coleifer/peewee/issues/1375
271,094,627
MDU6SXNzdWUyNzEwOTQ2Mjc=
1,375
RecursionError when querying by postgresql_ext BinaryJSONField in pytest
{ "login": "cejohnson", "id": 2759726, "node_id": "MDQ6VXNlcjI3NTk3MjY=", "avatar_url": "https://avatars.githubusercontent.com/u/2759726?v=4", "gravatar_id": "", "url": "https://api.github.com/users/cejohnson", "html_url": "https://github.com/cejohnson", "followers_url": "https://api.github.com/users/cejohnson/followers", "following_url": "https://api.github.com/users/cejohnson/following{/other_user}", "gists_url": "https://api.github.com/users/cejohnson/gists{/gist_id}", "starred_url": "https://api.github.com/users/cejohnson/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/cejohnson/subscriptions", "organizations_url": "https://api.github.com/users/cejohnson/orgs", "repos_url": "https://api.github.com/users/cejohnson/repos", "events_url": "https://api.github.com/users/cejohnson/events{/privacy}", "received_events_url": "https://api.github.com/users/cejohnson/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I believe this is a PyTest problem. Peewee uses recursive-descent to convert the AST into SQL. Given that it runs fine outside the py.test suite, I'd suggest you file this with the py.test developers.", "@coleifer thanks for the quick response. I found a similar open issue there, I'll follow up with the py.test developers.\r\n\r\nhttps://github.com/pytest-dev/pytest/issues/2724", "Looks like I jumped the gun a little. I was able to recreate this issue using plain unittest, so I dug into it a little further using pdb. The root issue, as far as I can tell, appears to be that calling `self.interpolation` on a JsonLookup object returns itself as a param, leading to the recursion error at line 1894/1899 of parse_node. Why this would only happen during testing I have no idea; I'm pretty new to the Python ecosystem, so I'm not sure if it's doing anything differently when testing. Same thing happens with 2.7 FWIW.\r\n\r\npdb output:\r\n```\r\n(Pdb) s\r\n--Call--\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1881)parse_node()\r\n-> def parse_node(self, node, alias_map=None, conv=None):\r\n(Pdb) s\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1882)parse_node()\r\n-> sql, params, unknown = self._parse(node, alias_map, conv)\r\n(Pdb) pp node\r\n<playhouse.postgres_ext.JsonLookup object at 0x1070248d0>\r\n(Pdb)\r\n\r\n...\r\n\r\n(Pdb) s\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1739)_parse_default()\r\n-> return self.interpolation, [node]\r\n(Pdb) s\r\n--Return--\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1739)_parse_default()->('%s', [<playhouse.po...t 0x1070248d0>])\r\n-> return self.interpolation, [node]\r\n(Pdb)\r\n\r\n...\r\n\r\n--Return--\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1879)_parse()->('%s', [<playhouse.po...t 0x1070248d0>], True)\r\n-> return sql, params, unknown\r\n(Pdb) \r\n\r\n...\r\n\r\n(Pdb) s\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1898)parse_node()\r\n-> if isinstance(param, Node):\r\n(Pdb) s\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1899)parse_node()\r\n-> csql, cparams = self.parse_node(param)\r\n(Pdb) pp param\r\n<playhouse.postgres_ext.JsonLookup object at 0x1070248d0>\r\n(Pdb) s\r\n--Call--\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1881)parse_node()\r\n-> def parse_node(self, node, alias_map=None, conv=None):\r\n(Pdb) s\r\n> /Users/chris/Projects/recursion_error/.venv/lib/python3.6/site-packages/peewee.py(1882)parse_node()\r\n-> sql, params, unknown = self._parse(node, alias_map, conv)\r\n(Pdb) pp node\r\n<playhouse.postgres_ext.JsonLookup object at 0x1070248d0>\r\n(Pdb)\r\n```", "I'm confused how something so fundamental could be an issue, as the `BinaryJSONField` is tested extensively in peewee's test suite. Furthermore, it's only happening in the tests?\r\n\r\nCan you add a test-case to Peewee that replicates the issue? See:\r\n\r\nhttps://github.com/coleifer/peewee/blob/f4ebd78b990efc6f0fc57b9a4d81f0cd6ecdf276/playhouse/tests/test_postgres.py#L606-L948", "So, turns out the issue is not with core peewee, but apparently with the playhouse db_url module, or at least how I was using it.\r\n\r\nInitializing the database with:\r\n```\r\n_database = peewee.Proxy()\r\n_database.initialize(connect(\"postgresql://test:test@localhost:5432/test\"))\r\n```\r\nresults in the RecursionError, while everything is fine when doing:\r\n```\r\n_database = peewee.Proxy()\r\n_database.initialize(postgres_ext.PostgresqlExtDatabase('test', user='test', password='test', host='localhost'))\r\n```\r\n\r\nWhether this is an actual problem with db_url or there was something else wrong with my configuration I'm not sure, but definitely an unintuitive error to track down. (Turns out we had been doing it the latter way in the actual project the whole time, which is presumably why the issue only appeared in testing. Whoops.)\r\n\r\nAnyway, thanks again for your time!", "Ahh, you can use the db_url module, but you need to use `postgresqlext` as the protocol.\r\n\r\nhttps://github.com/coleifer/peewee/blob/master/playhouse/db_url.py#L129", "LOL. Yep, that did it. I really appreciate your responsiveness, thanks again." ]
2017-11-03T19:30:34
2017-11-06T18:18:40
2017-11-06T17:41:37
NONE
null
Hello, I'm using postgresql_ext with peewee, and am getting a RecursionError when attempting to query by a BinaryJSONField key, i.e. ```python Model.select().where(Model.json['key'] == 'value') ``` This happens if you attempt to reference the field in at least the WHERE or ORDER BY clauses, and probably elsewhere. What is really strange is that this only happens when testing with pytest; the same query seems to works fine when you actually run it live, and if you use raw SQL that also works in both cases. Versions: ``` python: 3.6.2 peewee: 2.10.2 pytest: 3.2.3 ``` I'm attaching a minimal test case that for me results in the following: ``` $ pytest -v test_model.py ============================================================================================================================ test session starts ============================================================================================================================= platform darwin -- Python 3.6.2, pytest-3.2.3, py-1.4.34, pluggy-0.4.0 -- []/.venv/bin/python3.6 cachedir: .cache rootdir: [], inifile: plugins: cov-2.5.1, celery-4.1.0 collected 3 items test_model.py::test_select_basic PASSED test_model.py::test_raw_select_json PASSED test_model.py::test_select_json FAILED ================================================================================================================================== FAILURES ================================================================================================================================== ______________________________________________________________________________________________________________________________ test_select_json ______________________________________________________________________________________________________________________________ def test_select_json(): Model.drop_table(fail_silently=True) Model.create_table() Model.create(json={'key': 'value'}) # RecursionError models = Model.select().where(Model.json['key'] == 'value') > assert len(models) == 1 test_model.py:53: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../.venv/lib/python3.6/site-packages/peewee.py:3298: in __len__ return len(self.execute()) ../.venv/lib/python3.6/site-packages/peewee.py:3274: in execute self._qr = ResultWrapper(model_class, self._execute(), query_meta) ../.venv/lib/python3.6/site-packages/peewee.py:2938: in _execute sql, params = self.sql() ../.venv/lib/python3.6/site-packages/peewee.py:3240: in sql return self.compiler().generate_select(self) ../.venv/lib/python3.6/site-packages/peewee.py:2043: in generate_select return self.build_query(clauses, alias_map) ../.venv/lib/python3.6/site-packages/peewee.py:1929: in build_query return self.parse_node(Clause(*clauses), alias_map) ../.venv/lib/python3.6/site-packages/peewee.py:1882: in parse_node sql, params, unknown = self._parse(node, alias_map, conv) ../.venv/lib/python3.6/site-packages/peewee.py:1848: in _parse sql, params = self._parse_map[node_type](node, alias_map, conv) ../.venv/lib/python3.6/site-packages/peewee.py:1774: in _parse_clause node.nodes, alias_map, conv, node.glue) ../.venv/lib/python3.6/site-packages/peewee.py:1907: in parse_node_list node_sql, node_params = self.parse_node(node, alias_map, conv) ../.venv/lib/python3.6/site-packages/peewee.py:1882: in parse_node sql, params, unknown = self._parse(node, alias_map, conv) E RecursionError: maximum recursion depth exceeded while calling a Python object !!! Recursion detected (same locals & position) ``` I'm not sure if this might somehow be a pytest issue since I've only seen it when testing, but I figured I'd go ahead and start here. Apologies in advance if this is documented somewhere or I'm doing something dumb, and thanks for your time! [test_model.py.txt](https://github.com/coleifer/peewee/files/1442250/test_model.py.txt) (This should work basically out of the box, just need to change the postgresql connection string)
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1375/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/1375/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1374
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1374/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1374/comments
https://api.github.com/repos/coleifer/peewee/issues/1374/events
https://github.com/coleifer/peewee/issues/1374
270,259,615
MDU6SXNzdWUyNzAyNTk2MTU=
1,374
Join.metadata doesn't seem to respect Join.on enough
{ "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
[ "Before I dig into this specific issue, do you mind giving things a try with 3.0a and letting me know if it resolves the issue?", "This appears to be working correctly in the 3.0a branch:\r\n\r\n```python\r\nfrom peewee import *\r\n\r\ndb = SqliteDatabase(':memory:')\r\n\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = db\r\n\r\nclass Owner(BaseModel):\r\n name = CharField()\r\n\r\nclass Cat(BaseModel):\r\n owner = ForeignKeyField(Owner)\r\n name = CharField()\r\n\r\nclass Rat(BaseModel):\r\n owner = ForeignKeyField(Owner, null=True)\r\n caught_by = ForeignKeyField(Cat, null=True)\r\n name = CharField()\r\n\r\ndb.create_tables([Owner, Cat, Rat])\r\n\r\no1 = Owner.create(name='o1')\r\no2 = Owner.create(name='o2')\r\n\r\nc11 = Cat.create(name='c1-1', owner=o1)\r\nc12 = Cat.create(name='c1-2', owner=o1)\r\nc21 = Cat.create(name='c2-1', owner=o2)\r\n\r\nr11 = Rat.create(name='r1-1', caught_by=c11)\r\nr12 = Rat.create(name='r1-2', caught_by=c12)\r\nr1x = Rat.create(name='r1-x', owner=o2)\r\n\r\nr21 = Rat.create(name='r2-1', caught_by=c21, owner=o2)\r\nr22 = Rat.create(name='r2-2', caught_by=c21)\r\n\r\nquery = (Rat\r\n .select(Rat, Owner)\r\n .join(Cat, JOIN.LEFT_OUTER)\r\n .switch(Rat)\r\n .join(Owner, JOIN.LEFT_OUTER, on=(\r\n fn.COALESCE(Rat.owner, Cat.owner) == Owner.id).alias('_real_owner')))\r\nfor row in query:\r\n print row.name, row._real_owner.__data__\r\n```\r\n\r\nPRINTS:\r\n\r\n```\r\nr1-1 {'id': 1, 'name': u'o1'}\r\nr1-2 {'id': 1, 'name': u'o1'}\r\nr1-x {'id': 2, 'name': u'o2'}\r\nr2-1 {'id': 2, 'name': u'o2'}\r\nr2-2 {'id': 2, 'name': u'o2'}\r\n```" ]
2017-11-01T10:16:05
2017-11-15T22:28:07
2017-11-15T22:28:07
CONTRIBUTOR
null
Here's what I found in the `Join` code while debugging: ```python fk_field, is_backref = self.get_foreign_key(src, dest, self.on) if fk_field is None and self.on is not None: fk_field, is_backref = self.get_foreign_key(src, dest) ``` I don't understand why Peewee here decides to choose __any__ foreign key pointing to `dest`, even if I clearly asked it to use a certain `self.on` for it. It feels like a very non-obvious and, I'd say, useless fallback behavior which not so much fixes things as breaks them. Here's my situation, simplified. I have a `Rat` object which can remember which `Cat` caught this rat though `Rat.cat`. Either `Rat` and `Cat` object (or both) can have an owner: `Rat.owner`, `Cat.owner`. After a rat is being caught by a cat, the cat's owner becomes indirectly the rat's owner, too. So, I want to list all the rats with their owners, either direct (`rat.owner`) or indirect (`rat.cat.owner`). I do this using join expression with alias `_real_owner`: ```python Rat.select() \ .join(Cat) \ .switch(Rat) \ .join(Person, JOIN_LEFT_OUTER, on=(fn.coalesce(Rat.owner, Cat.owner) == Person.id).alias('_real_owner')) ``` But when it comes to the piece of code I showed in the beginning, Peewee seems to look at it this way: — So, do we have a foreign key Rat→Person with name `_real_owner`? — No, we don't. — Ok, nevermind, do we have **any** foreign key Rat→Person? — Yes, we do: there is a foreign key named `owner`. It isn't what we were asked for, but it's Rat→Person. — Let's use it. As a result of this, `Join.metadata.foreign_key.name` is now `'owner'`, and later it causes `ModelQueryResultWrapper.follow_joins()` to try and get `inst._data['owner']` (which is `None`) and quit trying to fill `_real_owner` in the resulting row: ```python has_fk = True if check_null: if fk_present: has_fk = inst._data.get(metadata.foreign_key.name) elif pk_present: has_fk = joined_inst._data.get(metadata.primary_key.name) if not has_fk: continue ... setattr(inst, metadata.attr, joined_inst) ``` I believe that either the first or the last piece of code does something wrong. Existence of `Rat.owner` should not affect ability to make custom joins of `Person` in the query, **or**, even if it is useful to have `metadata.foreign_key` for some other cases, its name should not affect the decision about whether or not to fill `Rat._real_owner` (because `metadata.attr == '_real_owner'`).
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1374/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/1374/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1373
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1373/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1373/comments
https://api.github.com/repos/coleifer/peewee/issues/1373/events
https://github.com/coleifer/peewee/issues/1373
269,924,098
MDU6SXNzdWUyNjk5MjQwOTg=
1,373
how to do cross database join
{ "login": "hongweishang", "id": 6167917, "node_id": "MDQ6VXNlcjYxNjc5MTc=", "avatar_url": "https://avatars.githubusercontent.com/u/6167917?v=4", "gravatar_id": "", "url": "https://api.github.com/users/hongweishang", "html_url": "https://github.com/hongweishang", "followers_url": "https://api.github.com/users/hongweishang/followers", "following_url": "https://api.github.com/users/hongweishang/following{/other_user}", "gists_url": "https://api.github.com/users/hongweishang/gists{/gist_id}", "starred_url": "https://api.github.com/users/hongweishang/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/hongweishang/subscriptions", "organizations_url": "https://api.github.com/users/hongweishang/orgs", "repos_url": "https://api.github.com/users/hongweishang/repos", "events_url": "https://api.github.com/users/hongweishang/events{/privacy}", "received_events_url": "https://api.github.com/users/hongweishang/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "能不能在不同数据库间join并不是peewee能决定的。比如MySQL,同一个服务的不同数据库间是可以join的,但是不同服务就不要想了。\r\n\r\n更明确一点,你定义Model的时候,是用的同一个peewee.Database 实例还是不同的Database实例,这决定了你到底能不能在不同的数据库之间join", "@yanghg-basefx 数据库用的是MYSQL,MYSQL本身是支持cross db join的, 用raw sql是没有问题的;\r\n两个model分别是不同的database属性(_meta.database)。\r\n看了下peewee源码,它确实不支持cross db join,即使用model.select().join()...这样构造出的sql语句在cross db join的情况下是错误的。\r\n请问是否有peewee cross db join的方案?(不使用raw sql)", "哦可能我理解错你的问题了。peewee默认想要用join的话必须有一个 \r\nForeignKeyField,如果没有的话在compile SQL语句的时候会报错。所以如果想要 \r\n用M.select.join()你首先要在他们之间建立一个连接,哪怕是假的连接也行。\r\n\r\n然后,如果你没有指定on条件的话,peewee会根据你的连接自动生成,类似于(ON \r\nM2.m1_id = M1.id),所以你必须要指定一条一定为True的on条件。\r\n\r\n根据这个原理,我们就可以伪造出一条只能用来CROSS JOIN的语句了。\r\n\r\nclass M1(Model):\r\n\r\n class Meta:\r\n database = MySQLDatabase(**M1_CFG)\r\n db_table ='m1'\r\n\r\n\r\nclass M2(Model):\r\n m1 = ForeignKeyField(M1,'m2s',db_column='id')\r\n\r\n class Meta:\r\n database = MySQLDatabase(**M2_CFG)\r\n db_table ='m2'\r\nfor m2 in M2.select(M2, M1).join(M1,join_type='CROSS JOIN',on=M2.id.is_null(False)):\r\n print m2.id,\r\n print m2.m1.id", "If you need to prefix your models with the database name, you can try using the `schema` model metadata option. Example:\r\n\r\n```python\r\nclass MyModel(Model):\r\n data = TextField()\r\n class Meta:\r\n database = db1\r\n schema = 'db1'\r\n\r\nMyModel.select().sql()\r\n# SELECT \"t1\".\"id\", \"t1\".\"data\" FROM \"db1\".\"mymodel\" AS \"t1\"\r\n```", "thanks" ]
2017-10-31T11:27:22
2017-11-03T13:59:22
2017-11-03T13:59:22
NONE
null
dm.A.select(dm.A.id, cm.B.name).join(cm.B, on=(dm.A.type==cm.B.id)) <class 'data_models.TRepFlow'> SELECT `t3`.`id`, `t2`.`name` FROM `t_rep_flow` AS t1 INNER JOIN `t_sys_app` AS t2 ON (`t2`.`id` = `t1`.`itemtype`) [] question: A and B are models. A and B is not in the same db. So, how to do cross db join?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1373/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/1373/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1372
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1372/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1372/comments
https://api.github.com/repos/coleifer/peewee/issues/1372/events
https://github.com/coleifer/peewee/issues/1372
268,587,724
MDU6SXNzdWUyNjg1ODc3MjQ=
1,372
BoolField for Sqlite does't get mapped to a boolean value
{ "login": "nad2000", "id": 177266, "node_id": "MDQ6VXNlcjE3NzI2Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/177266?v=4", "gravatar_id": "", "url": "https://api.github.com/users/nad2000", "html_url": "https://github.com/nad2000", "followers_url": "https://api.github.com/users/nad2000/followers", "following_url": "https://api.github.com/users/nad2000/following{/other_user}", "gists_url": "https://api.github.com/users/nad2000/gists{/gist_id}", "starred_url": "https://api.github.com/users/nad2000/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/nad2000/subscriptions", "organizations_url": "https://api.github.com/users/nad2000/orgs", "repos_url": "https://api.github.com/users/nad2000/repos", "events_url": "https://api.github.com/users/nad2000/events{/privacy}", "received_events_url": "https://api.github.com/users/nad2000/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Two reasons for that. One, sqlite has no boolean type. Two, in python true is literally the same as 1 and false is 0.", "Thanks for the comment. I was aware of that. That's why I thing it would be handy to have uniform type coercion. Original issue I ran into was that marshalling select query results into JSON with Sqlite3 and PG produces different output. I was expecting that mapping (isn't that what ORM is supposed to do) would shield me form limitations of the underlying DBs. Cheers!", "The values *are* coerced, though. It's just the storage type:\r\n\r\n```ipython\r\nIn [1]: from peewee import *\r\n\r\nIn [2]: db = SqliteDatabase(':memory:')\r\n\r\nIn [3]: class Test(Model):\r\n ...: value = BooleanField()\r\n ...: class Meta:\r\n ...: database = db\r\n ...: \r\n\r\nIn [4]: db.create_tables([Test])\r\n\r\nIn [5]: t = Test.create(value=True)\r\n\r\nIn [6]: f = Test.create(value=False)\r\n\r\nIn [7]: print Test.get(Test.id == t.id).value\r\nTrue\r\n\r\nIn [8]: print Test.get(Test.id == f.id).value\r\nFalse\r\n```" ]
2017-10-25T23:58:21
2017-10-27T13:59:58
2017-10-27T13:59:58
NONE
null
BoolField for Sqlite does't get mapped to a boolean value. Instead its DB representation (INTEGER) value gets returned.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1372/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/1372/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1371
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1371/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1371/comments
https://api.github.com/repos/coleifer/peewee/issues/1371/events
https://github.com/coleifer/peewee/issues/1371
268,277,039
MDU6SXNzdWUyNjgyNzcwMzk=
1,371
How to specify an icu tokenizer locale identifier for subclass of sqlite_ext.FTSModel?
{ "login": "galeo", "id": 1025559, "node_id": "MDQ6VXNlcjEwMjU1NTk=", "avatar_url": "https://avatars.githubusercontent.com/u/1025559?v=4", "gravatar_id": "", "url": "https://api.github.com/users/galeo", "html_url": "https://github.com/galeo", "followers_url": "https://api.github.com/users/galeo/followers", "following_url": "https://api.github.com/users/galeo/following{/other_user}", "gists_url": "https://api.github.com/users/galeo/gists{/gist_id}", "starred_url": "https://api.github.com/users/galeo/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/galeo/subscriptions", "organizations_url": "https://api.github.com/users/galeo/orgs", "repos_url": "https://api.github.com/users/galeo/repos", "events_url": "https://api.github.com/users/galeo/events{/privacy}", "received_events_url": "https://api.github.com/users/galeo/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "It seems that Peewee is quoting the tokenizer (both 2.x and 3.0a), it looks like:\r\n\r\n```sql\r\nCREATE VIRTUAL TABLE \"note\" USING FTS3 (\"content\", tokenize=\"icu en_AU\")\r\n```\r\n\r\nCan you do an experiment for me? Using Peewee (or just the plain old `sqlite3` module):\r\n\r\n```python\r\nfrom playhouse.sqlite_ext import *\r\ndb = SqliteExtDatabase(':memory:')\r\ndb.execute_sql('CREATE VIRTUAL TABLE thai_text USING fts3 (content, tokenize=icu th_TH);')\r\n```\r\n\r\nOr\r\n\r\n```python\r\nimport sqlite3\r\nconn = sqlite3.connect(':memory:')\r\nconn.execute('CREATE VIRTUAL TABLE thai_text USING fts3 (content, tokenize=icu th_TH);')\r\n```\r\n\r\nAnd let me know what happens?", "They work well, both of the methods above, by not quoting the tokenizer.", "Cool I didn't compile sqlite with icu so I wanted to double check that would work. I'll get a patch up today.", "Thanks!", "You mind trying out c88fc2ef08c4ed5e7214b7d30f0b20707db43995 and seeing if that resolves the issue?", "It works! Thanks so much!" ]
2017-10-25T06:10:19
2017-11-15T17:38:08
2017-11-15T17:38:08
NONE
null
Sqlite's built in icu tokenizer supports locale identifier, for example: ```sql CREATE VIRTUAL TABLE thai_text USING fts3(text, tokenize=icu th_TH) ``` If tried to set `Meta.extension_options = {'tokenize': 'icu th_TH'}`, it will raise error: ``` peewee.OperationalError: unknown tokenizer: icu th_TH ``` Does it support specify this option for subclass of `playhouse.sqlite_ext.FTSModel`?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1371/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/1371/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1370
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1370/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1370/comments
https://api.github.com/repos/coleifer/peewee/issues/1370/events
https://github.com/coleifer/peewee/issues/1370
267,881,639
MDU6SXNzdWUyNjc4ODE2Mzk=
1,370
Nested result in JSON format
{ "login": "rogercorrea", "id": 11555553, "node_id": "MDQ6VXNlcjExNTU1NTUz", "avatar_url": "https://avatars.githubusercontent.com/u/11555553?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rogercorrea", "html_url": "https://github.com/rogercorrea", "followers_url": "https://api.github.com/users/rogercorrea/followers", "following_url": "https://api.github.com/users/rogercorrea/following{/other_user}", "gists_url": "https://api.github.com/users/rogercorrea/gists{/gist_id}", "starred_url": "https://api.github.com/users/rogercorrea/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rogercorrea/subscriptions", "organizations_url": "https://api.github.com/users/rogercorrea/orgs", "repos_url": "https://api.github.com/users/rogercorrea/repos", "events_url": "https://api.github.com/users/rogercorrea/events{/privacy}", "received_events_url": "https://api.github.com/users/rogercorrea/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee has a helper called \"model_to_dict\" which can construct (recursively, if you desire) a dictionary containing model data, which can then be serialized as JSON.\r\n\r\nhttp://docs.peewee-orm.com/en/latest/peewee/playhouse.html#model_to_dict", "Thanks for answer, but I did try use backrefs parameter in model_to_dicts but don't worked for me.\r\n\r\n#My models:\r\n```\r\nclass TBEstados(BaseModel):\r\n ativo = IntegerField(null=True)\r\n nome = CharField()\r\n uf = CharField(null=True)\r\n\r\n class Meta:\r\n db_table = 'TBEstados'\r\n\r\nclass TBCidades(BaseModel):\r\n ativo = IntegerField(null=True)\r\n idestado = ForeignKeyField(db_column='idEstado', null=True, rel_model=TBEstados, to_field='id', backrefs=True)\r\n nome = CharField(null=True)\r\n\r\n class Meta:\r\n db_table = 'TBCidades\r\n```\r\n#select data \r\n\r\n`data = TBCidades.select().where(TBCidades.idestado == idEstado and TBCidades.ativo == True).dicts()`\r\n\r\n#Calling the model_to_dict function\r\n\r\n```\r\ndef toJSON(obj):\r\n obj = [model_to_dict(t, backrefs=True) for t in obj]\r\n return jsonify(obj)\r\n```\r\n\r\n#result JSON\r\n```\r\n[\r\n {\r\n \"ativo\": 1, \r\n \"id\": 1, \r\n \"idestado\": 1, \r\n \"nome\": \"Acrel\\u00e2ndia\"\r\n }\r\n]\r\n```", "You want `recurse=True` if the foreign key is on the model you're attempting to serialize.", "Thanks, but I did try use recurse=True and don't work.\r\n```\r\n\r\ndef toJSON(obj):\r\n obj = [model_to_dict(t, recurse=True) for t in obj]\r\n return jsonify(obj)\r\n```\r\n\r\nI ask me if haven't problem in my model." ]
2017-10-24T03:01:51
2017-10-24T17:14:08
2017-10-24T15:24:37
NONE
null
Please, How can I use a query with Peewee to return a JSON format with Nested objects? Example: ``` [ { "active": 1, "id": 1, "name": "Los Angeles", "idState": 2, "TBState": { "id": 2, "name": "California" } } ] ``` I can it using SqlAlchemy using relationship by model but in Peewee I don't know as make. Thanks!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1370/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/1370/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1369
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1369/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1369/comments
https://api.github.com/repos/coleifer/peewee/issues/1369/events
https://github.com/coleifer/peewee/issues/1369
267,426,891
MDU6SXNzdWUyNjc0MjY4OTE=
1,369
peewee.OperationalError: row value misused
{ "login": "kalimalrazif", "id": 2915349, "node_id": "MDQ6VXNlcjI5MTUzNDk=", "avatar_url": "https://avatars.githubusercontent.com/u/2915349?v=4", "gravatar_id": "", "url": "https://api.github.com/users/kalimalrazif", "html_url": "https://github.com/kalimalrazif", "followers_url": "https://api.github.com/users/kalimalrazif/followers", "following_url": "https://api.github.com/users/kalimalrazif/following{/other_user}", "gists_url": "https://api.github.com/users/kalimalrazif/gists{/gist_id}", "starred_url": "https://api.github.com/users/kalimalrazif/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/kalimalrazif/subscriptions", "organizations_url": "https://api.github.com/users/kalimalrazif/orgs", "repos_url": "https://api.github.com/users/kalimalrazif/repos", "events_url": "https://api.github.com/users/kalimalrazif/events{/privacy}", "received_events_url": "https://api.github.com/users/kalimalrazif/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "My guess is that the value of `Link` is from a previous call to `get_or_create`, which returns a 2-tuple of `<model instance>, <bool created?>`.\r\n\r\nCan you verify whether the value of `Link` is a tuple?", "Was that precisely!!! Thanks!!!", "If you forget that `get_or_create` returns a tuple and you try to save another model using the result as a field value, you can also get an error like the following: \r\n\r\n`TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple'`\r\n\r\n(Adding this comment as Google-bait so the next person who gets this error finds the answer sooner.)" ]
2017-10-22T01:18:53
2022-01-18T17:16:57
2017-10-24T15:24:48
NONE
null
Hi, I'm getting this messages when I try to get_or_create a record on db. This is the model on sqlite ```python class BaseModel(Model): class Meta: database = db class Compania(BaseModel): name = TextField(null=False) url = TextField() country = TextField() state = TextField() city = TextField() procesado = BooleanField(default=False) class Visitados(BaseModel): url = TextField() class Facebook(BaseModel): compania = ForeignKeyField(Compania,related_name='facebooks') link = ForeignKeyField(Visitados, related_name='enlaces_a_facebooks') url = TextField() ``` From previous querys I have link and compania, and pass the objects, when I try to issue this command: `resp = Facebook.get_or_create(url=url_a_chequear, link=de_donde_viene, compania=que_cia)` got: ```python Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/peewee.py", line 3830, in execute_sql cursor.execute(sql, params or ()) sqlite3.OperationalError: row value misused During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/nomar/Documents/Trabajos/Connexa/hubspot/005.py", line 254, in <module> main() File "/home/nomar/Documents/Trabajos/Connexa/hubspot/005.py", line 237, in main if procesa_url(url_pagina, link, compania) is not None: File "/home/nomar/Documents/Trabajos/Connexa/hubspot/005.py", line 158, in procesa_url resp = Facebook.get_or_create(url=url_a_chequear, link=de_donde_viene, compania=que_cia) File "/usr/lib/python3.6/site-packages/peewee.py", line 5001, in get_or_create return query.get(), False File "/usr/lib/python3.6/site-packages/peewee.py", line 3220, in get return next(clone.execute()) File "/usr/lib/python3.6/site-packages/peewee.py", line 3274, in execute self._qr = ResultWrapper(model_class, self._execute(), query_meta) File "/usr/lib/python3.6/site-packages/peewee.py", line 2939, in _execute return self.database.execute_sql(sql, params, self.require_commit) File "/usr/lib/python3.6/site-packages/peewee.py", line 3837, in execute_sql self.commit() File "/usr/lib/python3.6/site-packages/peewee.py", line 3656, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "/usr/lib/python3.6/site-packages/peewee.py", line 135, in reraise raise value.with_traceback(tb) File "/usr/lib/python3.6/site-packages/peewee.py", line 3830, in execute_sql cursor.execute(sql, params or ()) peewee.OperationalError: row value misused ``` Looking into the code notice this is the raw query: `<class 'modelo.Facebook'> SELECT "t1"."id", "t1"."compania_id", "t1"."link_id", "t1"."url" FROM "facebook" AS t1 WHERE ((("t1"."url" = ?) AND ("t1"."link_id" = (?, ?))) AND ("t1"."compania_id" = ?)) ['https://www.facebook.com/XXXXXXXX', 1, 0, 1]` Why `("t1"."link_id" = (?, ?))` hast two values?!?!?! I used peewee to create tables. Any advice? Thanks in advance Nomar
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1369/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/1369/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1368
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1368/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1368/comments
https://api.github.com/repos/coleifer/peewee/issues/1368/events
https://github.com/coleifer/peewee/pull/1368
267,281,881
MDExOlB1bGxSZXF1ZXN0MTQ3ODc4NDgw
1,368
Add support for using verbose names as CSV header values
{ "login": "brandond", "id": 370103, "node_id": "MDQ6VXNlcjM3MDEwMw==", "avatar_url": "https://avatars.githubusercontent.com/u/370103?v=4", "gravatar_id": "", "url": "https://api.github.com/users/brandond", "html_url": "https://github.com/brandond", "followers_url": "https://api.github.com/users/brandond/followers", "following_url": "https://api.github.com/users/brandond/following{/other_user}", "gists_url": "https://api.github.com/users/brandond/gists{/gist_id}", "starred_url": "https://api.github.com/users/brandond/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/brandond/subscriptions", "organizations_url": "https://api.github.com/users/brandond/orgs", "repos_url": "https://api.github.com/users/brandond/repos", "events_url": "https://api.github.com/users/brandond/events{/privacy}", "received_events_url": "https://api.github.com/users/brandond/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "CSV module is no longer included in Peewee as of 3.0.0.", "@coleifer is there a suggested replacement? This was a great simple way to dump stuff out.", "The dumping code is just a thin wrapper: https://github.com/coleifer/peewee/blob/stable/playhouse/csv_utils.py\r\n\r\nYou can easily backport it into your codebase." ]
2017-10-20T19:34:27
2018-02-01T00:57:38
2018-01-31T12:30:13
NONE
null
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1368/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/1368/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1368", "html_url": "https://github.com/coleifer/peewee/pull/1368", "diff_url": "https://github.com/coleifer/peewee/pull/1368.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1368.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1367
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1367/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1367/comments
https://api.github.com/repos/coleifer/peewee/issues/1367/events
https://github.com/coleifer/peewee/issues/1367
266,767,578
MDU6SXNzdWUyNjY3Njc1Nzg=
1,367
joins and default values
{ "login": "LolusKekus", "id": 17664948, "node_id": "MDQ6VXNlcjE3NjY0OTQ4", "avatar_url": "https://avatars.githubusercontent.com/u/17664948?v=4", "gravatar_id": "", "url": "https://api.github.com/users/LolusKekus", "html_url": "https://github.com/LolusKekus", "followers_url": "https://api.github.com/users/LolusKekus/followers", "following_url": "https://api.github.com/users/LolusKekus/following{/other_user}", "gists_url": "https://api.github.com/users/LolusKekus/gists{/gist_id}", "starred_url": "https://api.github.com/users/LolusKekus/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/LolusKekus/subscriptions", "organizations_url": "https://api.github.com/users/LolusKekus/orgs", "repos_url": "https://api.github.com/users/LolusKekus/repos", "events_url": "https://api.github.com/users/LolusKekus/events{/privacy}", "received_events_url": "https://api.github.com/users/LolusKekus/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I understand your thinking, but unfortunately I'm worried about the implications of modifying this behavior in the 2.x branch. Perhaps I can introduce such a change in 3.x, though?", "Fixed in 3.0a. No exception is raised, `None` is simply returned as the field value." ]
2017-10-19T08:55:13
2017-10-25T14:56:13
2017-10-25T14:56:13
NONE
null
Why peewee returns default values for joined tabels when i forgot to select this field? I have 2 models: ``` class ModelOne(Model): fieldOne = IntegerField(default=666) fieldTwo = IntegerField() class ModelTwo(Model): modelOne = ForeignKeyField(ModelOne) someField = IntegerField() ``` For the begininng I want to query ModelTwo with all fields in it and fieldTwo from ModelOne: ``` qs = ModelTwo.select(ModelTwo, ModelOne.fieldTwo).join(ModelOne) for i in qs: print(i.someField, i.modelone.fieldTwo) ``` Ok, it's work, i'm happy. BUT suddenly i understand that i need fieldOne from ModelOne too. I don't know, maybe becaus of my inattentive, i do next thing: ``` qs = ModelTwo.select(ModelTwo, ModelOne.fieldTwo).join(ModelOne) for i in qs: print(i.someField, i.modelone.fieldTwo, i.modelone.fieldOne) ``` I'm completely forgot to insert **ModelOne.fieldOne** in **select()** section and what i did get? **default** value for **fieldOne**: 666 I think this isn't right. Maybe better raise an error that i forgot to add fieldOne in select section?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1367/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/1367/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1366
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1366/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1366/comments
https://api.github.com/repos/coleifer/peewee/issues/1366/events
https://github.com/coleifer/peewee/pull/1366
266,025,591
MDExOlB1bGxSZXF1ZXN0MTQ2OTY2MTYw
1,366
Add clear explanations about the implications of SQLite having foreign keys off by default, in combination with default PrimaryKeyField ID reuse.
{ "login": "bryhoyt", "id": 4769854, "node_id": "MDQ6VXNlcjQ3Njk4NTQ=", "avatar_url": "https://avatars.githubusercontent.com/u/4769854?v=4", "gravatar_id": "", "url": "https://api.github.com/users/bryhoyt", "html_url": "https://github.com/bryhoyt", "followers_url": "https://api.github.com/users/bryhoyt/followers", "following_url": "https://api.github.com/users/bryhoyt/following{/other_user}", "gists_url": "https://api.github.com/users/bryhoyt/gists{/gist_id}", "starred_url": "https://api.github.com/users/bryhoyt/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/bryhoyt/subscriptions", "organizations_url": "https://api.github.com/users/bryhoyt/orgs", "repos_url": "https://api.github.com/users/bryhoyt/repos", "events_url": "https://api.github.com/users/bryhoyt/events{/privacy}", "received_events_url": "https://api.github.com/users/bryhoyt/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Very nice, thank you!" ]
2017-10-17T07:51:46
2017-10-17T14:34:01
2017-10-17T14:34:01
CONTRIBUTOR
null
To address the problems raised in #550
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1366/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/1366/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1366", "html_url": "https://github.com/coleifer/peewee/pull/1366", "diff_url": "https://github.com/coleifer/peewee/pull/1366.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1366.patch", "merged_at": "2017-10-17T14:34:01" }
https://api.github.com/repos/coleifer/peewee/issues/1365
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1365/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1365/comments
https://api.github.com/repos/coleifer/peewee/issues/1365/events
https://github.com/coleifer/peewee/issues/1365
265,927,897
MDU6SXNzdWUyNjU5Mjc4OTc=
1,365
how are join keys determined?
{ "login": "ra-esmith", "id": 24212262, "node_id": "MDQ6VXNlcjI0MjEyMjYy", "avatar_url": "https://avatars.githubusercontent.com/u/24212262?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ra-esmith", "html_url": "https://github.com/ra-esmith", "followers_url": "https://api.github.com/users/ra-esmith/followers", "following_url": "https://api.github.com/users/ra-esmith/following{/other_user}", "gists_url": "https://api.github.com/users/ra-esmith/gists{/gist_id}", "starred_url": "https://api.github.com/users/ra-esmith/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ra-esmith/subscriptions", "organizations_url": "https://api.github.com/users/ra-esmith/orgs", "repos_url": "https://api.github.com/users/ra-esmith/repos", "events_url": "https://api.github.com/users/ra-esmith/events{/privacy}", "received_events_url": "https://api.github.com/users/ra-esmith/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I cannot tell you which foreign key to join on, only you would know that. To specify the key, in the join method add an `on` argument:\r\n\r\n```python\r\nSomething.select().join(Other, on=Other.some_field)\r\n```" ]
2017-10-16T21:50:59
2017-10-17T14:38:24
2017-10-17T14:38:24
NONE
null
I am getting the error 17:43:04 web.1 | ValueError: More than one foreign key between <class 'sample_models.X'> and <class 'sample_models.Y'>. How do I determine which keys to join on? I think this is the query that is at issue. In the old peewee I did not specify anyting related to the keys to join on (X.select(Y).join(Y).where(...) What is the correct syntax. I am using the foreign keys in the where clause ... Both of my classes X and Y have several foreign keys defined. How did the last version resolve which ones to use ? Thanks [OKAY] Loaded ENV .env File as KEY=VALUE Format 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92954] [INFO] Starting gunicorn 19.7.1 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92954] [INFO] Listening at: http://0.0.0.0:5000 (92954) 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92954] [INFO] Using worker: gevent 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92957] [INFO] Booting worker with pid: 92957 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92958] [INFO] Booting worker with pid: 92958 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92959] [INFO] Booting worker with pid: 92959 17:41:39 web.1 | [2017-10-16 17:41:39 -0400] [92960] [INFO] Booting worker with pid: 92960 17:43:04 web.1 | [2017-10-16 17:43:04 -0400] [92959] [ERROR] Error handling request / 17:43:04 web.1 | Traceback (most recent call last): 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/async.py", line 56, in handle 17:43:04 web.1 | self.handle_request(listener_name, req, client, addr) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 152, in handle_request 17:43:04 web.1 | super(GeventWorker, self).handle_request(*args) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/async.py", line 107, in handle_request 17:43:04 web.1 | respiter = self.wsgi(environ, resp.start_response) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__ 17:43:04 web.1 | return self.wsgi_app(environ, start_response) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app 17:43:04 web.1 | response = self.handle_exception(e) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception 17:43:04 web.1 | reraise(exc_type, exc_value, tb) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app 17:43:04 web.1 | response = self.full_dispatch_request() 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request 17:43:04 web.1 | rv = self.handle_user_exception(e) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception 17:43:04 web.1 | reraise(exc_type, exc_value, tb) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request 17:43:04 web.1 | rv = self.dispatch_request() 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request 17:43:04 web.1 | return self.view_functions[rule.endpoint](**req.view_args) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/auth.py", line 129, in inner 17:43:04 web.1 | return fn(*args, **kwargs) 17:43:04 web.1 | File "/Users/anon/Desktop/xxx/sample-master/views/dashboards.py", line 96, in main_page 17:43:04 web.1 | return get_dashboard_for_y(modelXX.y, user, user.rep_id) 17:43:04 web.1 | File "/Users/anon/Desktop/xxx/sample-master/views/dashboards.py", line 300, in get_dashboard_for_y 17:43:04 web.1 | .join(Y) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/peewee.py", line 595, in inner 17:43:04 web.1 | method(clone, *args, **kwargs) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/peewee.py", line 5123, in join 17:43:04 web.1 | on, attr, constructor = self._normalize_join(src, dest, on, attr) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/peewee.py", line 5092, in _normalize_join 17:43:04 web.1 | src_model, dest_model, to_field, on) 17:43:04 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/peewee.py", line 5160, in _generate_on_clause 17:43:04 web.1 | (src, dest)) 17:43:04 web.1 | ValueError: More than one foreign key between <class 'sample_models.X'> and <class 'sample_models.Y'>. Please specify which you are joining on. 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:29 web.1 | [2017-10-16 17:43:29 -0400] [92954] [INFO] Handling signal: winch 17:43:30 web.1 | [2017-10-16 17:43:30 -0400] [92954] [INFO] Handling signal: winch 17:43:30 web.1 | [2017-10-16 17:43:30 -0400] [92954] [INFO] Handling signal: winch 17:43:30 web.1 | [2017-10-16 17:43:30 -0400] [92954] [INFO] Handling signal: winch 17:43:30 web.1 | [2017-10-16 17:43:30 -0400] [92954] [INFO] Handling signal: winch 17:43:30 web.1 | [2017-10-16 17:43:30 -0400] [92954] [INFO] Handling signal: winch 17:43:30 web.1 | [2017-10-16 17:43:30 -0400] [92954] [INFO] Handling signal: winch
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1365/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/1365/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1364
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1364/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1364/comments
https://api.github.com/repos/coleifer/peewee/issues/1364/events
https://github.com/coleifer/peewee/issues/1364
265,879,324
MDU6SXNzdWUyNjU4NzkzMjQ=
1,364
crash on startup with port from 2 to 3a
{ "login": "ra-esmith", "id": 24212262, "node_id": "MDQ6VXNlcjI0MjEyMjYy", "avatar_url": "https://avatars.githubusercontent.com/u/24212262?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ra-esmith", "html_url": "https://github.com/ra-esmith", "followers_url": "https://api.github.com/users/ra-esmith/followers", "following_url": "https://api.github.com/users/ra-esmith/following{/other_user}", "gists_url": "https://api.github.com/users/ra-esmith/gists{/gist_id}", "starred_url": "https://api.github.com/users/ra-esmith/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ra-esmith/subscriptions", "organizations_url": "https://api.github.com/users/ra-esmith/orgs", "repos_url": "https://api.github.com/users/ra-esmith/repos", "events_url": "https://api.github.com/users/ra-esmith/events{/privacy}", "received_events_url": "https://api.github.com/users/ra-esmith/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You need the 3.0a branches of wtf-peewee and flask-peewee, if your project depends on those libraries. Since I haven't merged 3.0a into master yet, you'll need to use the branches. When 3.0a is merged into peewee master, I'll merge the other libraries as well." ]
2017-10-16T19:02:33
2017-10-16T20:08:48
2017-10-16T20:08:48
NONE
null
Thought I would try the 3.0a version I was running peewee==2.10.1 did a pip uninstall of peewee and then installed peewee 3.0a And then just ran my code ... Got some errors right off ... ideas? Is there a list of changes we should make to port up? For example "importError: cannot import name PrimaryKeyField" Thanks! Some more details [OKAY] Loaded ENV .env File as KEY=VALUE Format 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91297] [INFO] Starting gunicorn 19.7.1 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91297] [INFO] Listening at: http://0.0.0.0:5000 (91297) 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91297] [INFO] Using worker: gevent 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91300] [INFO] Booting worker with pid: 91300 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91301] [INFO] Booting worker with pid: 91301 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91302] [INFO] Booting worker with pid: 91302 14:56:37 web.1 | [2017-10-16 14:56:37 -0400] [91303] [INFO] Booting worker with pid: 91303 14:56:38 web.1 | [2017-10-16 14:56:38 -0400] [91301] [ERROR] Exception in worker process 14:56:38 web.1 | Traceback (most recent call last): 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:56:38 web.1 | worker.init_process() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:56:38 web.1 | super(GeventWorker, self).init_process() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:56:38 web.1 | self.load_wsgi() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:56:38 web.1 | self.wsgi = self.app.wsgi() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:56:38 web.1 | self.callable = self.load() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 14:56:38 web.1 | return self.load_wsgiapp() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:56:38 web.1 | return util.import_app(self.app_uri) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:56:38 web.1 | __import__(module) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/main.py", line 29, in <module> 14:56:38 web.1 | from views.user import * 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/views/user.py", line 18, in <module> 14:56:38 web.1 | from sample1_auth import sample1_auth 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_auth.py", line 17, in <module> 14:56:38 web.1 | from sample1_models import User, UserAdmin 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_models.py", line 44, in <module> 14:56:38 web.1 | from flask_peewee.admin import ModelAdmin 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:56:38 web.1 | from flask_peewee.filters import FilterForm 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:56:38 web.1 | from flask_peewee.forms import BaseModelConverter 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:56:38 web.1 | from wtfpeewee.orm import ModelConverter 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:56:38 web.1 | from peewee import PrimaryKeyField 14:56:38 web.1 | ImportError: cannot import name PrimaryKeyField 14:56:38 web.1 | [2017-10-16 14:56:38 -0400] [91301] [INFO] Worker exiting (pid: 91301) 14:56:38 web.1 | [2017-10-16 14:56:38 -0400] [91300] [ERROR] Exception in worker process 14:56:38 web.1 | Traceback (most recent call last): 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:56:38 web.1 | worker.init_process() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:56:38 web.1 | super(GeventWorker, self).init_process() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:56:38 web.1 | self.load_wsgi() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:56:38 web.1 | self.wsgi = self.app.wsgi() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:56:38 web.1 | self.callable = self.load() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-package 14:56:38 web.1 | s/gunicorn/app/wsgiapp.py", line 65, in load 14:56:38 web.1 | return self.load_wsgiapp() 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:56:38 web.1 | return util.import_app(self.app_uri) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:56:38 web.1 | __import__(module) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/main.py", line 29, in <module> 14:56:38 web.1 | from views.user import * 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/views/user.py", line 18, in <module> 14:56:38 web.1 | from sample1_auth import sample1_auth 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versio 14:56:38 web.1 | ns/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_auth.py", line 17, in <module> 14:56:38 web.1 | from sample1_models import User, UserAdmin 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_models.py", line 44, in <module> 14:56:38 web.1 | from flask_peewee.admin import ModelAdmin 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:56:38 web.1 | from flask_peewee.filters import FilterForm 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import 14:56:38 web.1 | __ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:56:38 web.1 | from flask_peewee.forms import BaseModelConverter 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:56:38 web.1 | from wtfpeewee.orm import ModelConverter 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:38 web.1 | result = _import(*args, **kwargs) 14:56:38 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:56:38 web.1 | from peewee import PrimaryKeyField 14:56:38 web.1 | ImportError: cannot import name PrimaryKeyField 14:56:38 web.1 | [2017-10-16 14:56:38 -0400] [91300] [INFO] Worker exiting (pid: 91300) 14:56:39 web.1 | [2017-10-16 14:56:39 -0400] [91303] [ERROR] Exception in worker process 14:56:39 web.1 | Traceback (most recent call last): 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:56:39 web.1 | worker.init_process() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:56:39 web.1 | super(GeventWorker, self).init_process() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:56:39 web.1 | self.load_wsgi() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:56:39 web.1 | self.wsgi = self.app.wsgi() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:56:39 web.1 | self.callable = self.load() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 14:56:39 web.1 | return self.load_wsgiapp() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:56:39 web.1 | return util.import_app(self.app_uri) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:56:39 web.1 | __import__(module) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/main.py", line 29, in <module> 14:56:39 web.1 | from views.user import * 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/views/user.py", line 18, in <module> 14:56:39 web.1 | from sample1_auth import sample1_auth 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_auth.py", line 17, in <module> 14:56:39 web.1 | from sample1_models import User, UserAdmin 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_models.py", line 44, in <module> 14:56:39 web.1 | from flask_peewee.admin import ModelAdmin 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:56:39 web.1 | from flask_peewee.filters import FilterForm 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:56:39 web.1 | from flask_peewee.forms import BaseModelConverter 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:56:39 web.1 | from wtfpeewee.orm import ModelConverter 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:56:39 web.1 | from peewee import PrimaryKeyField 14:56:39 web.1 | ImportError: cannot import name PrimaryKeyField 14:56:39 web.1 | [2017-10-16 14:56:39 -0400] [91303] [INFO] Worker exiting (pid: 91303) 14:56:39 web.1 | [2017-10-16 14:56:39 -0400] [91302] [ERROR] Exception in worker process 14:56:39 web.1 | Traceback (most recent call last): 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:56:39 web.1 | worker.init_process() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:56:39 web.1 | super(GeventWorker, self).init_process() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:56:39 web.1 | self.load_wsgi() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:56:39 web.1 | self.wsgi = self.app.wsgi() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:56:39 web.1 | self.callable = self.load() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 14:56:39 web.1 | return self.load_wsgiapp() 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:56:39 web.1 | return util.import_app(self.app_uri) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:56:39 web.1 | __import__(module) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/main.py", line 29, in <module> 14:56:39 web.1 | from views.user import * 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/views/user.py", line 18, in <module> 14:56:39 web.1 | from sample1_auth import sample1_auth 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_auth.py", line 17, in <module> 14:56:39 web.1 | from sample1_models import User, UserAdmin 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Users/anon/Desktop/xxx/sample1-master/sample1_models.py", line 44, in <module> 14:56:39 web.1 | from flask_peewee.admin import ModelAdmin 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:56:39 web.1 | from flask_peewee.filters import FilterForm 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:56:39 web.1 | from flask_peewee.forms import BaseModelConverter 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:56:39 web.1 | from wtfpeewee.orm import ModelConverter 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:56:39 web.1 | result = _import(*args, **kwargs) 14:56:39 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:56:39 web.1 | from peewee import PrimaryKeyField 14:56:39 web.1 | ImportError: cannot import name PrimaryKeyField 14:56:39 web.1 | [2017-10-16 14:56:39 -0400] [91302] [INFO] Worker exiting (pid: 91302) 14:56:39 web.1 | [2017-10-16 14:56:39 -0400] [91297] [INFO] Shutting down: Master 14:56:39 web.1 | [2017-10-16 14:56:39 -0400] [91297] [INFO] Reason: Worker failed to boot. 14:56:39 web.1 Exited with exit code 3
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1364/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/1364/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1363
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1363/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1363/comments
https://api.github.com/repos/coleifer/peewee/issues/1363/events
https://github.com/coleifer/peewee/issues/1363
265,510,748
MDU6SXNzdWUyNjU1MTA3NDg=
1,363
ManyToMany-Field creation throws an IntegrityError "Duplicate entry for key"
{ "login": "greece57", "id": 9194851, "node_id": "MDQ6VXNlcjkxOTQ4NTE=", "avatar_url": "https://avatars.githubusercontent.com/u/9194851?v=4", "gravatar_id": "", "url": "https://api.github.com/users/greece57", "html_url": "https://github.com/greece57", "followers_url": "https://api.github.com/users/greece57/followers", "following_url": "https://api.github.com/users/greece57/following{/other_user}", "gists_url": "https://api.github.com/users/greece57/gists{/gist_id}", "starred_url": "https://api.github.com/users/greece57/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/greece57/subscriptions", "organizations_url": "https://api.github.com/users/greece57/orgs", "repos_url": "https://api.github.com/users/greece57/repos", "events_url": "https://api.github.com/users/greece57/events{/privacy}", "received_events_url": "https://api.github.com/users/greece57/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Can't replicate:\r\n\r\n```python\r\nfrom peewee import *\r\nfrom playhouse.fields import ManyToManyField\r\n\r\ndatabase = SqliteDatabase(':memory:')\r\n\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = database\r\n\r\nclass Hashtag(BaseModel):\r\n tag = TextField()\r\n\r\nclass Article(BaseModel):\r\n title = TextField()\r\n hashtags = ManyToManyField(Hashtag, related_name='articles')\r\n\r\nThroughModel = Article.hashtags.get_through_model()\r\n\r\ndatabase.create_tables([\r\n Hashtag,\r\n Article,\r\n ThroughModel])\r\n\r\narticle = Article(title='testing')\r\narticle.save()\r\n\r\nht1 = Hashtag.create(tag='ht1')\r\nht2 = Hashtag.create(tag='ht2')\r\narticle.hashtags.add([ht1, ht2])\r\narticle.save()\r\n\r\narticle_db = Article.get(Article.title == 'testing')\r\nfor ht in article_db.hashtags:\r\n print ht.tag\r\n```\r\n\r\nThe above code prints \"ht1\" and \"ht2\" as expected.", "I can't replicate it either on purpose :/\r\nI'm parsing a lot of data and suddenly it happens again and again..\r\nBut only on that element.\r\n\r\nI posted it here because the Error Message seams to be incorrect. Do you maybe have an idea how I can find out more about it or what I should do next to find the problem?", "Please see this line:\r\n\r\n```python\r\nhashtags = get_hashtag() # hashtags is an array of already saved hashtag-peewee-Model-Objects\r\n```\r\n\r\nI think your get_hashtag function have some problem, so the hashtags have duplicating-objects.\r\n\r\nI reproduced it by this script:\r\n\r\n```python\r\nhashtags = list(HashTag.select())\r\nhashtags = hashtags.extend(hashtags)\r\n```\r\n\r\nA easy way to test, you can try:\r\n\r\n```python\r\nhashtags = list(set(get_hashtag())) # hashtags is an array of already saved hashtag-peewee-Model-Objects\r\n```", "@yanghg-basefx thank you! Most likely that was the problem and now it seems to be working fine :+1: \r\n\r\nI didn't think of interpreting the error message that way!" ]
2017-10-14T17:57:49
2017-10-17T12:33:41
2017-10-17T12:33:41
NONE
null
I don't know where that error is coming from, thats why I want to ask here. I'm doing the following: ``` class Article(BaseModel): time = pw.DateTimeField() # ... hashtags = ManyToManyField(Hashtag, related_name='articles') topics = ManyToManyField(Topic, related_name='topics') text = pw.TextField() class Hashtag(BaseModel): tag = pw.CharField() ``` And then during execution: ``` article = Article(time=published_utc_datetime, ...) # I define every thing in here which is not a ManyToMany Field hashtags = get_hashtag() # hashtags is an array of already saved hashtag-peewee-Model-Objects article.save() article.hashtags.add(hashtags) # <- Here I get the Error article.save() ``` This is the Error: `peewee.IntegrityError, (1062, "Duplicate entry '7-91' for key 'article_hashtag_through_article_id_hashtag_id'")` The thing is that when I look into the table there is no entry for an Entry with article_id 7 and hashtag_id 91. Its actually the first entry in this table for article_id 7. ``` MariaDB [database]> SELECT * FROM article_hashtag_through WHERE article_id = 7; Empty set (0.00 sec) ``` This is the database description: ``` MariaDB [database]> describe article_hashtag_through; +------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+---------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | article_id | int(11) | NO | MUL | NULL | | | hashtag_id | int(11) | NO | MUL | NULL | | +------------+---------+------+-----+---------+----------------+ ``` I hope you can help me with this because I really don't understand the problem.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1363/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/1363/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1362
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1362/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1362/comments
https://api.github.com/repos/coleifer/peewee/issues/1362/events
https://github.com/coleifer/peewee/issues/1362
265,473,562
MDU6SXNzdWUyNjU0NzM1NjI=
1,362
An InterfaceError was not catched only in PostgreSQLDatabase
{ "login": "yanghg-basefx", "id": 29534214, "node_id": "MDQ6VXNlcjI5NTM0MjE0", "avatar_url": "https://avatars.githubusercontent.com/u/29534214?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yanghg-basefx", "html_url": "https://github.com/yanghg-basefx", "followers_url": "https://api.github.com/users/yanghg-basefx/followers", "following_url": "https://api.github.com/users/yanghg-basefx/following{/other_user}", "gists_url": "https://api.github.com/users/yanghg-basefx/gists{/gist_id}", "starred_url": "https://api.github.com/users/yanghg-basefx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yanghg-basefx/subscriptions", "organizations_url": "https://api.github.com/users/yanghg-basefx/orgs", "repos_url": "https://api.github.com/users/yanghg-basefx/repos", "events_url": "https://api.github.com/users/yanghg-basefx/events{/privacy}", "received_events_url": "https://api.github.com/users/yanghg-basefx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Why are you closing the connection in the middle of iterating over a cursor? That makes no sense.", "This is only a reproducing. The problem is this issue often happened because some network fault so the connection was closed in the middle of iterating. \r\n\r\nIt is only happened between two different city's database connection in our company, and we can't make the connection much better.", "Gotcha -- you'll probably need to implement this on your end as some kind of \"re-connecting\" logic. But as far as integrating into peewee, that's above-and-beyond the scope of the project.", "OK, I see." ]
2017-10-14T08:01:54
2017-10-17T21:53:19
2017-10-16T14:57:39
NONE
null
I have searched this issue, and it looks like #334 I can reproduce this problem by this code: ```python from a_postgresql_module import MyModel for instance in MyModel.select(): print instance.id MyModel._meta.database.close() ``` This issue seems like postgresql will close a cursor automatically after the connection was closed by any reason, for example between a long time iteration, if something bad was happened so the connection was accidentally closed, and the cursor can't be re-opened. mysql doesn't have this problem, because its cursor never be closed. I have a bad idea to solve that: ```python class QueryResultWrapper(object): def __init__(self, model, cursor, meta=None, query=None): ... self.query=query ... def iterate(self): try: row = self.cursor.fetchone() except psycopg2.InterfaceError: self.cursor = self.query.execute().cursor row = self.cursor.fetchone() while row and self.process_row(row) in self._result_cache: row = self.cursor.fetchone() ... class SelectQuery(Query): ... def execute(self): if self._dirty or self._qr is None: ... self._qr = ResultWrapper(model_class, self._execute(), query_meta, self) ... ... ``` That means if the error was happened, I will try to rebuild a cursor, and go to the last iterated point. Be easy to see, this is a bad class structure. And if someone else insert a new row between the old result wrapper's caches, the result will be wrong. Another way to avoid this error is fetching all the data one times. But both these two ideas are not the best choice. So what's your idea? Or just wrap this error and add this case to the document and tell any developers to catch it in their own tools?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1362/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/1362/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1361
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1361/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1361/comments
https://api.github.com/repos/coleifer/peewee/issues/1361/events
https://github.com/coleifer/peewee/issues/1361
264,487,266
MDU6SXNzdWUyNjQ0ODcyNjY=
1,361
DateTimeField get <unicode> instead of <datetime> in special case
{ "login": "icewisb", "id": 28560844, "node_id": "MDQ6VXNlcjI4NTYwODQ0", "avatar_url": "https://avatars.githubusercontent.com/u/28560844?v=4", "gravatar_id": "", "url": "https://api.github.com/users/icewisb", "html_url": "https://github.com/icewisb", "followers_url": "https://api.github.com/users/icewisb/followers", "following_url": "https://api.github.com/users/icewisb/following{/other_user}", "gists_url": "https://api.github.com/users/icewisb/gists{/gist_id}", "starred_url": "https://api.github.com/users/icewisb/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/icewisb/subscriptions", "organizations_url": "https://api.github.com/users/icewisb/orgs", "repos_url": "https://api.github.com/users/icewisb/repos", "events_url": "https://api.github.com/users/icewisb/events{/privacy}", "received_events_url": "https://api.github.com/users/icewisb/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What version of Peewee? What database driver?", "Closing due to inactivity.", "My peewee is 2.10.2 in python2, this case only appear when I use three tables. It disappeared when I leave two talbes", "Database driver is mysqldb.", "That's rather odd. Is there a reason you're using the call to `.alias()` all over the place instead of using the models themselves? What happens if you remove the calls to `alias()`?", "Ok,I will try it tomorrow. and I have an anther issue about BlobField , I use this field to store Binary img object successfully, but when I get this record use peewee why I get unicode object instead of binary object.\r\n", "```\r\nquery = SaoMstr.select(fn.MIN(SaoShip.ShipDate).alias('min_date'), SaoStyle.Style) \\\r\n .join(SaoShip, on=(SaoShip.OrderNo == SaoMstr.OrderNo)).join(SaoStyle, on=(SaoStyle.OrderNo == SaoMstr.OrderNo)) \\\r\n .where(SaoMstr.ExtTerm7 == '001', SaoMstr.Customer == '10011').group_by(SaoStyle.Style)\r\n\r\nIn [28]: type(query.get().min_date)\r\nOut[28]: unicode\r\n```\r\nWhen I delete ```SaoStyle.Style```:\r\n```query = SaoMstr.select(fn.MIN(SaoShip.ShipDate).alias('min_date')) \\\r\n .join(SaoShip, on=(SaoShip.OrderNo == SaoMstr.OrderNo)) \\\r\n .switch(SaoMstr).join(SaoStyle, on=(SaoStyle.OrderNo == SaoMstr.OrderNo).alias('st')) \\\r\n .where(SaoMstr.ExtTerm7 == '001', SaoMstr.Customer == '10011').group_by(SaoStyle.Style)\r\n\r\nIn [34]: type(query.get().min_date)\r\nOut[34]: datetime.datetime\r\n```\r\nAnd the following thing is very strange.\r\n```\r\nquery = SaoShip.select(fn.MIN(SaoShip.ShipDate).alias('min_date'), SaoStyle.Style).join(SaoStyle, on=(SaoStyle.OrderNo == SaoShip.OrderNo)).where(SaoShip.OrderNo == '0001000000001').group_by(SaoStyle.Style)\r\n\r\nIn [47]: type(query.get().min_date)\r\nOut[47]: unicode\r\n\r\n```\r\nWhat cause it ?\r\n\r\n\r\n\r\n", "Can you create a minimal example I can use to try and replicate this issue?" ]
2017-10-11T07:46:16
2018-10-19T07:23:45
2017-11-15T17:38:20
NONE
null
With use of fn.MAX and join 3 tables and group_by, I can't get DateTimeField with type <datetime> correctly. ```python from peewee import JOIN, fn from server.models import SaoShip, SaoMstr, SaoStyle store = '001' company = '10011' m = SaoMstr.alias() t = SaoStyle.alias() s = SaoShip.alias() query = m.select(fn.MIN(s.ShipDate).alias('min_end_date')) \ .join(s, on=(s.OrderNo == m.OrderNo)) \ .join(t, on=(t.OrderNo == m.OrderNo)) \ .where(m.ExtTerm7 == store, m.Customer == company)\ .group_by(t.OrderNo, t.Style) record = query.get() print type(record.min_end_date) ``` Terminal output : ```shell <type 'unicode'> ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1361/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/1361/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1360
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1360/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1360/comments
https://api.github.com/repos/coleifer/peewee/issues/1360/events
https://github.com/coleifer/peewee/issues/1360
263,717,974
MDU6SXNzdWUyNjM3MTc5NzQ=
1,360
AttributeError: 'NoneType' object has no attribute 'sqlite_version_info'
{ "login": "avish-3pg", "id": 22098240, "node_id": "MDQ6VXNlcjIyMDk4MjQw", "avatar_url": "https://avatars.githubusercontent.com/u/22098240?v=4", "gravatar_id": "", "url": "https://api.github.com/users/avish-3pg", "html_url": "https://github.com/avish-3pg", "followers_url": "https://api.github.com/users/avish-3pg/followers", "following_url": "https://api.github.com/users/avish-3pg/following{/other_user}", "gists_url": "https://api.github.com/users/avish-3pg/gists{/gist_id}", "starred_url": "https://api.github.com/users/avish-3pg/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/avish-3pg/subscriptions", "organizations_url": "https://api.github.com/users/avish-3pg/orgs", "repos_url": "https://api.github.com/users/avish-3pg/repos", "events_url": "https://api.github.com/users/avish-3pg/events{/privacy}", "received_events_url": "https://api.github.com/users/avish-3pg/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Try 8ba62478f7ce4fc3890fad0d1c42e851a382bdd4 ?", "Closing due to inactivity." ]
2017-10-08T13:29:34
2017-10-16T14:58:16
2017-10-16T14:58:16
NONE
null
@coleifer Still facing the sqlite3 issue, even though we are using peewee==2.10.1. Please advice at the earliest. Thank you. Error Stack Trace - 'NoneType' object has no attribute 'sqlite_version_info': AttributeError Traceback (most recent call last): File "/var/task/handler.py", line 511, in lambda_handler return LambdaHandler.lambda_handler(event, context) File "/var/task/handler.py", line 242, in lambda_handler return handler.handler(event, context) File "/var/task/handler.py", line 335, in handler app_function = self.import_module_and_get_function(whole_function) File "/var/task/handler.py", line 233, in import_module_and_get_function app_module = importlib.import_module(module) File "/var/lang/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/var/task/schedular.py", line 16, in <module> import models_postgres as models File "/var/task/models_postgres.py", line 4, in <module> from playhouse.db_url import connect File "/var/task/playhouse/db_url.py", line 118, in <module> from playhouse.berkeleydb import BerkeleyDatabase File "/var/task/playhouse/berkeleydb.py", line 10, in <module> sqlite3_lib_version = sqlite3.sqlite_version_info AttributeError: 'NoneType' object has no attribute 'sqlite_version_info'
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1360/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/1360/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1359
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1359/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1359/comments
https://api.github.com/repos/coleifer/peewee/issues/1359/events
https://github.com/coleifer/peewee/pull/1359
263,420,509
MDExOlB1bGxSZXF1ZXN0MTQ1MTMzODkx
1,359
Database URL extension for retrieving endpoint information from AWS RDS
{ "login": "mguillau", "id": 3710154, "node_id": "MDQ6VXNlcjM3MTAxNTQ=", "avatar_url": "https://avatars.githubusercontent.com/u/3710154?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mguillau", "html_url": "https://github.com/mguillau", "followers_url": "https://api.github.com/users/mguillau/followers", "following_url": "https://api.github.com/users/mguillau/following{/other_user}", "gists_url": "https://api.github.com/users/mguillau/gists{/gist_id}", "starred_url": "https://api.github.com/users/mguillau/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mguillau/subscriptions", "organizations_url": "https://api.github.com/users/mguillau/orgs", "repos_url": "https://api.github.com/users/mguillau/repos", "events_url": "https://api.github.com/users/mguillau/events{/privacy}", "received_events_url": "https://api.github.com/users/mguillau/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Because I'm not interested in maintaining this functionality, I'd suggest packaging this as a standalone project.", "It seems like the schema resolver change would be necessary to build this as an independent package.", "Thanks for the comments. I can easily re-submit a patch containing only the schema resolution part in db_url. Indeed, this would make it much easier to create standalone extensions as suggested. Would such a pull-request be of enough interest to you?" ]
2017-10-06T11:50:48
2017-10-09T09:42:20
2017-10-06T15:06:43
NONE
null
This pull-request adds an extension to playhouse's database URL mechanism to handle two new URL schemes, namely rds:// and rdsro:// (for rds "read-only"). These schemes simplify the use of AWS' Relational Database Service (RDS). Through boto3 (the main python SDK for AWS), RDS can provide the host endpoint (rw or ro), its port, the master username and the database engine type (mysql, postgresql, aurora and mariadb supported for far in this patch) to any authorised AWS users, from just the database id (a case-insensitive string). With this information, it is then easy to build the actual database URL for peewee/playhouse to use for connecting. For instance, one could provide the simple url "rds://test_db_user:test_db_pass@test_rds_db_id" which would automatically resolve to "mysql://test_db_user:test_db_pass@test_rds_db.ceqrivboeuyrbj.us-west-2.rds.amazonaws.com:5555/testdb" (assuming the RDS instance is mysql-compatible, listening on port 5555, etc.). The benefit is that the URL does not need to be changed as one manages its RDS database (changing the port, replacing hosts, adding replication and growing the fleet, etc.) The main idea of the patch is to provide the function that converts a parsed rds:// or rdsro:// url into the corresponding parsed mysql:// or postgresql:// URL (dynamically determined depending on the engine type). The commit also provides a mechanism to add more such functions to resolve parsed URLs into new parsed URLs. Potential applications for this mechanism include reading database URLs or passwords from environment variables, configuration files, else other secret-sharing services (those applications are left for future pull requests). Looking forward to comments and suggestions!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1359/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/1359/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1359", "html_url": "https://github.com/coleifer/peewee/pull/1359", "diff_url": "https://github.com/coleifer/peewee/pull/1359.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1359.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1358
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1358/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1358/comments
https://api.github.com/repos/coleifer/peewee/issues/1358/events
https://github.com/coleifer/peewee/issues/1358
263,203,680
MDU6SXNzdWUyNjMyMDM2ODA=
1,358
Mapping class inheritance hierarchies
{ "login": "apotapov", "id": 131698, "node_id": "MDQ6VXNlcjEzMTY5OA==", "avatar_url": "https://avatars.githubusercontent.com/u/131698?v=4", "gravatar_id": "", "url": "https://api.github.com/users/apotapov", "html_url": "https://github.com/apotapov", "followers_url": "https://api.github.com/users/apotapov/followers", "following_url": "https://api.github.com/users/apotapov/following{/other_user}", "gists_url": "https://api.github.com/users/apotapov/gists{/gist_id}", "starred_url": "https://api.github.com/users/apotapov/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/apotapov/subscriptions", "organizations_url": "https://api.github.com/users/apotapov/orgs", "repos_url": "https://api.github.com/users/apotapov/repos", "events_url": "https://api.github.com/users/apotapov/events{/privacy}", "received_events_url": "https://api.github.com/users/apotapov/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm not familiar with the SQLAlchemy implementation or behavior, but with Peewee inheriting a class creates a completely separate table with all the columns from the parent plus whatever is defined on the child class. There are no magic foreign-keys or anything like that.", "Thanks for a quick response.\r\n\r\nSingle Table Inheritance (STI) is a fairly common pattern: https://en.wikipedia.org/wiki/Single_Table_Inheritance It make querying much simpler at the base class level, meanwhile abstracting implementation to child classes. It's also standard in Rails.\r\n\r\nI was planning to use peewee for an app that I'm migrating from Rails to Flask, but not having STI is a non-starter for me. Would love to see it as a feature added in the future. For now, SQLAlchemy will have to make do.", "👍 \r\n\r\nBusiness model is not like database table, it encapsulates **behavior** besides data.\r\n\r\nThere is a common case that different models have similar data structure but behavior differently. With OOD, these models could be designed as subclasses inherited from one base class and overwriting some methods to get different behaviors.", "No disagreement here. You can subclass models in Peewee as long as you understand that the subclass will be its own table with no back-reference/pointer to the parent class table.", "I was simply pointing out that STI is a valid usecase for an ORM. And this feature seems to be missing from peewee. If that's by design, then that's fine. However, STI support would be much appreciated, especially to those of us coming from Rails world. And isn't that a win for the python ecosystem? ;)", "Don't you mean multi-table-inheritance (MTI)? Or maybe we're talking about the same thing...presenting a model class that composes (behind-the-scenes) the contents of two separate tables, related by a 1-to-1 from parent->child?\r\n\r\nThe problem with doing this kind of magic is that it touches nearly every complex part of peewee. Figuring out how to join two models now has a special-case. Figuring out how to map column data from a flat row returned by the cursor into a model graph also has a special-case. Selecting columns has a special case (do we need the join or can we get away without it, depending on the columns the user requests?). Etc.", "I think we are much more like talking about Single Table Inheritance(STI): different models share one single table, distinguished with value of a specific column, as [the SQLAlchemy example](http://docs.sqlalchemy.org/en/latest/orm/inheritance.html#single-table-inheritance).", "Ohhh, thanks @psjay I understand now. I glanced at the example without reading all the details. So SQLAlchemy maps all inherited columns onto a single table and then differentiates based on some type column. That's less smelly to me than multi-table-inheritance, but still is a level of magix that I don't want to maintain or have to debug :)" ]
2017-10-05T17:21:32
2017-10-13T14:15:46
2017-10-05T17:40:37
NONE
null
Pardon my ignorance, as I'm coming to python web frameworks from Rails-land. I'm wondering if peewee offers Single Table Inheritance similar to Rails. There seems to be an option for it in SQLAlchemy: http://docs.sqlalchemy.org/en/latest/orm/inheritance.html#single-table-inheritance If not, what are my options?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1358/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/1358/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1357
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1357/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1357/comments
https://api.github.com/repos/coleifer/peewee/issues/1357/events
https://github.com/coleifer/peewee/issues/1357
262,560,306
MDU6SXNzdWUyNjI1NjAzMDY=
1,357
More advanced index creation
{ "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 love it!", "When you're declaring an index inside the `Meta` attribute, the Python interpreter hasn't constructed the actual model class yet, so you can't do neat things like this:\r\n\r\n```python\r\nclass Article(Model):\r\n name = TextField()\r\n timestamp = TimestampField()\r\n status = IntegerField(default=1)\r\n flags = IntegerField(default=0)\r\n\r\n class Meta:\r\n indexes = (\r\n Index(fn.SUBSTR(Article.name, 1, 1), Article.timestamp.desc()).where(Article.status == 1),\r\n )\r\n```\r\n\r\nSo I think an alternative would be to simply allow `SQL()` objects to be included alongside the tuples? You'd have to specify the full SQL for the index, but at least that guarantees everything is supported. WDYT?", "Added in 3.0a" ]
2017-10-03T19:42:23
2017-11-29T20:17:53
2017-11-29T20:17:53
CONTRIBUTOR
null
Currently one can only define indexes using a tuple consisting of column names and uniqueness. With this construct it is not possible to create functional or partial indexes, for instance. While ways exist, it is a) what way is to be preferred and b) most often the declaration of that index will be somewhere else than all the other indexes of a table. I therefore suggest add an `Index` class that can be used in lieu of the tuple and which encapsulates the creation of index-related data (name, query). So, whenever one needs special constructs that peewee does not offer, a simple subclass is sufficient.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1357/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/1357/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1356
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1356/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1356/comments
https://api.github.com/repos/coleifer/peewee/issues/1356/events
https://github.com/coleifer/peewee/issues/1356
262,173,607
MDU6SXNzdWUyNjIxNzM2MDc=
1,356
Interface error connections already closed on ubuntu
{ "login": "vctrferreira", "id": 9720953, "node_id": "MDQ6VXNlcjk3MjA5NTM=", "avatar_url": "https://avatars.githubusercontent.com/u/9720953?v=4", "gravatar_id": "", "url": "https://api.github.com/users/vctrferreira", "html_url": "https://github.com/vctrferreira", "followers_url": "https://api.github.com/users/vctrferreira/followers", "following_url": "https://api.github.com/users/vctrferreira/following{/other_user}", "gists_url": "https://api.github.com/users/vctrferreira/gists{/gist_id}", "starred_url": "https://api.github.com/users/vctrferreira/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/vctrferreira/subscriptions", "organizations_url": "https://api.github.com/users/vctrferreira/orgs", "repos_url": "https://api.github.com/users/vctrferreira/repos", "events_url": "https://api.github.com/users/vctrferreira/events{/privacy}", "received_events_url": "https://api.github.com/users/vctrferreira/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "IDK, some weirdness in tornado? No idea, you might try StackOverflow or track down the original exception?", "This is the original traceback, you can help me? @coleifer \r\n\r\n```\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/tornado/web.py\", line 1467, in _stack_context_handle_exception\r\n raise_exc_info((type, value, traceback))\r\n File \"<string>\", line 4, in raise_exc_info\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/tornado/stack_context.py\", line 316, in wrapped\r\n ret = fn(*args, **kwargs)\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/tornado/web.py\", line 1680, in future_complete\r\n f.result()\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/tornado/concurrent.py\", line 238, in result\r\n raise_exc_info(self._exc_info)\r\n File \"<string>\", line 4, in raise_exc_info\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/tornado/gen.py\", line 292, in wrapper\r\n result = func(*args, **kwargs)\r\n File \"/home/app/webapp/env/lib/python3.5/types.py\", line 243, in wrapped\r\n coro = func(*args, **kwargs)\r\n File \"bothub/app/server.py\", line 230, in get\r\n answer = bm.ask(message, uuid)\r\n File \"bothub/app/server.py\", line 87, in ask\r\n questions_queue = self._get_questions_queue(bot_uuid)\r\n File \"bothub/app/server.py\", line 80, in _get_questions_queue\r\n return self._get_bot_data(bot_uuid)['questions_queue']\r\n File \"bothub/app/server.py\", line 65, in _get_bot_data\r\n instance = Bot.get(Bot.uuid == bot_uuid)\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 4926, in get\r\n return sq.get()\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 3181, in get\r\n return next(clone.execute())\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 3233, in execute\r\n self._qr = ResultWrapper(model_class, self._execute(), query_meta)\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 2912, in _execute\r\n return self.database.execute_sql(sql, params, self.require_commit)\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 3775, in execute_sql\r\n self.commit()\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 3598, in __exit__\r\n reraise(new_type, new_type(*exc_args), traceback)\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 135, in reraise\r\n raise value.with_traceback(tb)\r\n File \"/home/app/webapp/env/lib/python3.5/site-packages/peewee.py\", line 3768, in execute_sql\r\n cursor.execute(sql, params or ())\r\npeewee.OperationalError: SSL error: decryption failed or bad record mac\r\n```", "Something's the matter in your database connection, apparently." ]
2017-10-02T18:04:27
2017-10-02T19:17:15
2017-10-02T18:17:34
NONE
null
This is the traceback ``` During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/app/webapp/env/lib/python3.5/site-packages/tornado/web.py", line 1467, in _stack_context_handle_exception raise_exc_info((type, value, traceback)) File "<string>", line 4, in raise_exc_info File "/home/app/webapp/env/lib/python3.5/site-packages/tornado/stack_context.py", line 316, in wrapped ret = fn(*args, **kwargs) File "/home/app/webapp/env/lib/python3.5/site-packages/tornado/web.py", line 1680, in future_complete f.result() File "/home/app/webapp/env/lib/python3.5/site-packages/tornado/concurrent.py", line 238, in result raise_exc_info(self._exc_info) File "<string>", line 4, in raise_exc_info File "/home/app/webapp/env/lib/python3.5/site-packages/tornado/gen.py", line 292, in wrapper result = func(*args, **kwargs) File "/home/app/webapp/env/lib/python3.5/types.py", line 243, in wrapped coro = func(*args, **kwargs) File "bothub/app/server.py", line 230, in get answer = bm.ask(message, uuid) File "bothub/app/server.py", line 87, in ask questions_queue = self._get_questions_queue(bot_uuid) File "bothub/app/server.py", line 80, in _get_questions_queue return self._get_bot_data(bot_uuid)['questions_queue'] File "bothub/app/server.py", line 65, in _get_bot_data instance = Bot.get(Bot.uuid == bot_uuid) File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 4926, in get return sq.get() File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 3181, in get return next(clone.execute()) File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 3233, in execute self._qr = ResultWrapper(model_class, self._execute(), query_meta) File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 2912, in _execute return self.database.execute_sql(sql, params, self.require_commit) File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 3775, in execute_sql self.commit() File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 3598, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 135, in reraise raise value.with_traceback(tb) File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 3766, in execute_sql cursor = self.get_cursor() File "/home/app/webapp/env/lib/python3.5/site-packages/peewee.py", line 3714, in get_cursor return self.get_conn().cursor() peewee.InterfaceError: connection already closed ``` This is my code ``` from peewee import * from datetime import datetime from decouple import config import uuid DATABASE = PostgresqlDatabase( config('BOTHUB_POSTGRES_DB'), user=config('BOTHUB_POSTGRES_USER'), password=config('BOTHUB_POSTGRES_PASSWORD'), host=config('BOTHUB_POSTGRES'), port=config('BOTHUB_POSTGRES_PORT'), threadlocals=True) class BaseModel(Model): class Meta: database = DATABASE class Bot(BaseModel): uuid = UUIDField(primary_key=True, default=uuid.uuid4) bot = BlobField() created_at = DateTimeField(default=datetime.now) updated_at = DateTimeField() def save(self, *args, **kwargs): self.updated_at = datetime.now() return super(Bot, self).save(*args, **kwargs) class Meta: db_table = 'bots' ``` I don't know the reason for it, I saw a similar problem in issues (#334) and to "solved" it I did started my db with `threadlocals=True`, but it no solve my problem, you know to solve this?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1356/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/1356/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1355
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1355/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1355/comments
https://api.github.com/repos/coleifer/peewee/issues/1355/events
https://github.com/coleifer/peewee/issues/1355
262,108,532
MDU6SXNzdWUyNjIxMDg1MzI=
1,355
ArrayField and explicit type casts error
{ "login": "joaodlf", "id": 3275379, "node_id": "MDQ6VXNlcjMyNzUzNzk=", "avatar_url": "https://avatars.githubusercontent.com/u/3275379?v=4", "gravatar_id": "", "url": "https://api.github.com/users/joaodlf", "html_url": "https://github.com/joaodlf", "followers_url": "https://api.github.com/users/joaodlf/followers", "following_url": "https://api.github.com/users/joaodlf/following{/other_user}", "gists_url": "https://api.github.com/users/joaodlf/gists{/gist_id}", "starred_url": "https://api.github.com/users/joaodlf/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/joaodlf/subscriptions", "organizations_url": "https://api.github.com/users/joaodlf/orgs", "repos_url": "https://api.github.com/users/joaodlf/repos", "events_url": "https://api.github.com/users/joaodlf/events{/privacy}", "received_events_url": "https://api.github.com/users/joaodlf/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The fix to this was to update ArrayField(CharField) to ArrayField(TextField), since my fields are of type **text[]**. Doh." ]
2017-10-02T14:41:10
2017-10-02T15:35:03
2017-10-02T15:35:03
NONE
null
Hi, I'm using the latest version of peewee with Python 3.6, here is my code: ``` from playhouse.postgres_ext import * from config_constants import SQL_HOST, SQL_USER, SQL_PASSWORD, SQL_DATABASE database = PostgresqlExtDatabase(SQL_DATABASE, user=SQL_USER, password=SQL_PASSWORD, host=SQL_HOST, register_hstore=False) class BaseModel(Model): class Meta: database = database class Extras(BaseModel): id = PrimaryKeyField() utm_campaign = ArrayField(CharField) utm_medium = ArrayField(CharField) utm_source = ArrayField(CharField) utm_term = ArrayField(CharField) class Meta: db_table = "extras" where = [Extras.utm_source.contains("GoogleAdwords")] extras = Extras \ .select() \ .where(*where) for extra in extras: print(extra) ``` This is returning me the following: ``` Traceback (most recent call last): File "/Users/<snip>/env/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 383, in execute_sql cursor.execute(sql, params or ()) psycopg2.ProgrammingError: operator does not exist: text[] @> character varying[] LINE 1: ...erm" FROM "extras" AS t1 WHERE ("t1"."utm_source" @> ARRAY['... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "test.py", line 48, in <module> for extra in extras: File "/Users/<snip>/env/lib/python3.6/site-packages/peewee.py", line 3240, in __iter__ return iter(self.execute()) File "/Users/<snip>/env/lib/python3.6/site-packages/peewee.py", line 3233, in execute self._qr = ResultWrapper(model_class, self._execute(), query_meta) File "/Users/<snip>/env/lib/python3.6/site-packages/peewee.py", line 2912, in _execute return self.database.execute_sql(sql, params, self.require_commit) File "/Users/<snip>/env/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 390, in execute_sql self.commit() File "/Users/<snip>/env/lib/python3.6/site-packages/peewee.py", line 3598, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "/Users/<snip>/env/lib/python3.6/site-packages/peewee.py", line 135, in reraise raise value.with_traceback(tb) File "/Users/<snip>/env/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 383, in execute_sql cursor.execute(sql, params or ()) peewee.ProgrammingError: operator does not exist: text[] @> character varying[] LINE 1: ...erm" FROM "extras" AS t1 WHERE ("t1"."utm_source" @> ARRAY['... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ``` I'm assuming I'm doing something wrong here but can't put my finger on it. This is an issue when I attempt to iterate through the results, the "extras" variable actually does return an **playhouse.postgres_ext._Array** object. Querying for fields that are not of ArrayField type works as expected with no errors. Also, running a query in psql `SELECT * FROM extras WHERE utm_source @> ARRAY['Google Adwords'];` utm_source (like all other array fields in this example) is of type _text[]_.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1355/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/1355/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1354
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1354/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1354/comments
https://api.github.com/repos/coleifer/peewee/issues/1354/events
https://github.com/coleifer/peewee/issues/1354
261,177,666
MDU6SXNzdWUyNjExNzc2NjY=
1,354
"ambiguous column name: t1.id" on weird SQL query
{ "login": "franciscod", "id": 726447, "node_id": "MDQ6VXNlcjcyNjQ0Nw==", "avatar_url": "https://avatars.githubusercontent.com/u/726447?v=4", "gravatar_id": "", "url": "https://api.github.com/users/franciscod", "html_url": "https://github.com/franciscod", "followers_url": "https://api.github.com/users/franciscod/followers", "following_url": "https://api.github.com/users/franciscod/following{/other_user}", "gists_url": "https://api.github.com/users/franciscod/gists{/gist_id}", "starred_url": "https://api.github.com/users/franciscod/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/franciscod/subscriptions", "organizations_url": "https://api.github.com/users/franciscod/orgs", "repos_url": "https://api.github.com/users/franciscod/repos", "events_url": "https://api.github.com/users/franciscod/events{/privacy}", "received_events_url": "https://api.github.com/users/franciscod/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You probably need to use a model alias for the self-join on `caraggregate`.\r\n\r\n```python\r\nCarAggregateAlias = CarAggregate.alias()\r\n...\r\n.join(CarAggregateAlias, on=(CarAggregate.previous_self == CarAggregateAlias.id))\r\n```", "Hey Charles, thanks for helping :)\r\n\r\nI'm using `get_or_create` and don't see where I should use the model alias.\r\n\r\nMy reduced repro code looks like this:\r\n\r\nmodels.py:\r\n```py\r\n\r\nimport datetime\r\n\r\nfrom peewee import *\r\n\r\ndb = SqliteDatabase('db_weird_query.sqlite')\r\n\r\n\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = db\r\n\r\n\r\nclass Car(BaseModel):\r\n name = CharField()\r\n\r\n\r\nclass CarAggregate(BaseModel):\r\n finished = BooleanField(default=False)\r\n timestamp = DateTimeField(default=datetime.datetime.now)\r\n previous_self = ForeignKeyField('self', null=True, related_name='newer_self')\r\n car = ForeignKeyField(Car, related_name='aggregates')\r\n\r\n\r\ndb.create_tables([\r\n Car, CarAggregate,\r\n], safe=True)\r\n```\r\n\r\n```py\r\nfor car in Car.select():\r\n previous_aggregate = None\r\n for previous_aggregate in (\r\n CarAggregate.select().where(CarAggregate.car==car, CarAggregate.finished==True)\r\n .order_by(CarAggregate.timestamp.desc())):\r\n break\r\n\r\n # This fails\r\n aggr, cr = CarAggregate.get_or_create(\r\n previous_self=previous_aggregate,\r\n car=car,\r\n )\r\n\r\n print(\"get or c\", aggr, cr)\r\n```\r\n\r\nA workaround is to split the `get_or_create` into this...\r\n\r\n```py\r\ntry:\r\n aggr = CarAggregate.select().where(\r\n CarAggregate.previous_self==previous_aggregate,\r\n CarAggregate.car==car,\r\n CarAggregate.finished==True,\r\n ).order_by(CarAggregate.timestamp.desc()).get()\r\nexcept CarAggregate.DoesNotExist:\r\n aggr = CarAggregate.create(\r\n car=car,\r\n previous_self=previous_aggregate,\r\n )\r\n```\r\n\r\n...but I'm curious on why the `get_or_create` is generating that query and, again, is this a bug or a PEBKAC? :)", "Weird, it seems like a bug to me.", "I tested this in the 3.0a branch and it seems to be working as expected. I haven't tested this exactly in the latest 2.x yet, but first -- Is the code you shared in the get_or_create example exactly the code that triggered the error?", "Yep. I'll make a .py that reproduces this on 2.10.1", "... silly me. Couldn't reproduce and then I realized I have peewee installed both inside and outside the virtualenv. Inside it, with 2.10.1, it works as expected. It just happens on 2.6.4.\r\n\r\naghhhhhh sorry >.<", "This is the full code. I'll go and bisect 2.6.4 ~ 2.10.1 and see where it got fixed :)\r\n\r\n```py\r\n\r\nimport datetime\r\n\r\nfrom peewee import *\r\n\r\ndb = SqliteDatabase('db_weird_query.sqlite')\r\n\r\n\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = db\r\n\r\n\r\nclass Car(BaseModel):\r\n name = CharField()\r\n\r\n\r\nclass CarAggregate(BaseModel):\r\n finished = BooleanField(default=False)\r\n timestamp = DateTimeField(default=datetime.datetime.now)\r\n previous_self = ForeignKeyField('self', null=True, related_name='newer_self')\r\n car = ForeignKeyField(Car, related_name='aggregates')\r\n\r\n\r\ndb.create_tables([\r\n Car, CarAggregate,\r\n], safe=True)\r\n\r\ndef main():\r\n for name in ['foo', 'bar', 'baz']:\r\n car, _ = Car.get_or_create(\r\n name=name,\r\n )\r\n\r\n for car in Car.select():\r\n previous_aggregate = None\r\n for previous_aggregate in (CarAggregate.select().where(\r\n CarAggregate.car==car,\r\n CarAggregate.finished==True\r\n ).order_by(CarAggregate.timestamp.desc())):\r\n break\r\n\r\n aggr, cr = CarAggregate.get_or_create(\r\n previous_self=previous_aggregate,\r\n car=car,\r\n )\r\n\r\nif __name__ == '__main__':\r\n main()\r\n\r\n```", "```\r\n$ git bisect run python peeweebug.py\r\nrunning python peeweebug.py\r\n<__main__.CarAggregate object at 0x7fd7f098cda0> False\r\nBisecting: 145 revisions left to test after this (roughly 7 steps)\r\n[b65da77087abd86271fad78755d8580c124c0c26] Sqlite c extension cleanups.\r\nrunning python peeweebug.py\r\nambiguous column name: t1.id\r\nBisecting: 72 revisions left to test after this (roughly 6 steps)\r\n[f2f8a7381ba5aa4b9b9fad2349622d6bb9cbe2c7] Merge pull request #855 from lez/master\r\nrunning python peeweebug.py\r\n<__main__.CarAggregate object at 0x7f57934139e8> False\r\nBisecting: 36 revisions left to test after this (roughly 5 steps)\r\n[1d0edf9177a0fd502cbd627c930e56ad0837013b] Fix travis.yml\r\nrunning python peeweebug.py\r\nambiguous column name: t1.id\r\nBisecting: 18 revisions left to test after this (roughly 4 steps)\r\n[0480fcec5db77c0b161853d9ab49241f89cd23c3] Ensure get_or_create() works with new GFK API, refs #313\r\nrunning python peeweebug.py\r\n<__main__.CarAggregate object at 0x7fd90bbbc9b0> False\r\nBisecting: 8 revisions left to test after this (roughly 3 steps)\r\n[8473056690c1afdcf5bc8599c87a9f390ad9edc9] Fuck python 3.\r\nrunning python peeweebug.py\r\nambiguous column name: t1.id\r\nBisecting: 4 revisions left to test after this (roughly 2 steps)\r\n[35304d289391ae7fdab0f752ffada7faf2fc83dc] Warn if Cython is old, fixes #821.\r\nrunning python peeweebug.py\r\nambiguous column name: t1.id\r\nBisecting: 2 revisions left to test after this (roughly 1 step)\r\n[fa454e075de9befbfa281cc0e33f7a8c093e34fe] Fix typo.\r\nrunning python peeweebug.py\r\nambiguous column name: t1.id\r\nBisecting: 0 revisions left to test after this (roughly 1 step)\r\n[b42a86cc0343ab91b203625e67f7191f0ffcaaf3] Support equality / inequality with GFK in queries, fixes #313\r\nrunning python peeweebug.py\r\nambiguous column name: t1.id\r\n0480fcec5db77c0b161853d9ab49241f89cd23c3 is the first bad commit\r\ncommit 0480fcec5db77c0b161853d9ab49241f89cd23c3\r\nAuthor: Charles Leifer <[email protected]>\r\nDate: Wed Jan 20 12:21:22 2016 -0600\r\n\r\n Ensure get_or_create() works with new GFK API, refs #313\r\n\r\n:100644 100644 e45b89db35e2dea6a468847c21b2ac826e60fd94 af1457f69d9a0f28cbda4458a7ce122f684c4d06 M\tpeewee.py\r\n:040000 040000 64dc2b7aacce84f6dcdf78cf1225dfca6f11e38a 6ae72966a75ef4a6df4df87c981acf4e1d86288c M\tplayhouse\r\nbisect run success\r\n```\r\nWorking fine since Jan 2016 :)\r\n\r\nhttps://github.com/coleifer/peewee/commit/0480fcec5db77c0b161853d9ab49241f89cd23c3", "whaaaaat I'm on the thread referred by that commit\r\nhttps://github.com/coleifer/peewee/issues/313\r\n\r\ntripping twice on the same stone I guess :)", "LOL! Glad you're all set." ]
2017-09-28T02:52:09
2017-09-29T20:08:36
2017-09-29T00:54:20
CONTRIBUTOR
null
``` ('SELECT "t1"."id", "t1"."finished", "t1"."timestamp", "t1"."previous_self_id", "t1"."car_id", "t1"."best_hotlap_id", "t1"."laps_total" FROM "caraggregate" AS t1 INNER JOIN "car" AS t2 ON ( "t1"."car_id" = "t2"."id") INNER JOIN "caraggregate" AS t1 ON ( "t1"."previous_self_id" = "t1"."id") WHERE (( "t1"."car_id" = ?) AND ("t1"."previous_self_id" = ?)) LIMIT 1', [1, None]) ``` Is this query worth of investigating a bug or I'm just using something wrong? It seems weird to me that "t1" is bound twice to "caraggregate"...
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1354/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/1354/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1353
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1353/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1353/comments
https://api.github.com/repos/coleifer/peewee/issues/1353/events
https://github.com/coleifer/peewee/issues/1353
259,521,735
MDU6SXNzdWUyNTk1MjE3MzU=
1,353
Cannot specify schema with PostgresqlMigrator
{ "login": "irlabs", "id": 622169, "node_id": "MDQ6VXNlcjYyMjE2OQ==", "avatar_url": "https://avatars.githubusercontent.com/u/622169?v=4", "gravatar_id": "", "url": "https://api.github.com/users/irlabs", "html_url": "https://github.com/irlabs", "followers_url": "https://api.github.com/users/irlabs/followers", "following_url": "https://api.github.com/users/irlabs/following{/other_user}", "gists_url": "https://api.github.com/users/irlabs/gists{/gist_id}", "starred_url": "https://api.github.com/users/irlabs/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/irlabs/subscriptions", "organizations_url": "https://api.github.com/users/irlabs/orgs", "repos_url": "https://api.github.com/users/irlabs/repos", "events_url": "https://api.github.com/users/irlabs/events{/privacy}", "received_events_url": "https://api.github.com/users/irlabs/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You're right. You may need to, in the meantime, run something like `db.execute_sql('set search_path to my_schema')` until I can get a fix.", "Did you try the above suggestion, by chance?", "> Did you try the above suggestion, by chance?\r\n\r\nNo, I used the psql command line instead.", "Probably related, but I'm getting the same error using reflection on a Postgresql DB with a schema. `generate_models()` works fine but making a query on any of the generated models fails. If I do `db.execute_sql('set search_path to targetdb'`) the queries do work.", "@albireox -- check out febcb495de5f21bc19c8834af78522fbfdb6c994", "Yep, that seems to fix the problem.", "Rather than modify all the APIs to support a schema parameter, I added a method which you can use to set the search path for subsequent operations. e.g.\r\n\r\n```python\r\n\r\ntitle_field = TextField(default='')\r\nmigrate(\r\n migrator.set_search_path('my_schema'),\r\n migrator.add_column('some_table', 'title', title_field),\r\n)\r\n```" ]
2017-09-21T14:44:19
2018-02-09T15:50:33
2018-02-09T15:50:33
NONE
null
I'm trying to use `playhouse.migrate` to modify the database according to the model changes, but it seems I cannot specify the PostgreSQL schema of the table that I need to alter. My model looks like this: ```python db = PostgresqlDatabase(...) class MyTable(Model): title = CharField() class Meta: database = db db_table = 'table_name' schema = 'my_schema' ``` But if I run migration code like the following: ```python migrator = PostgresqlMigrator(db) new_field = CharField(default="") migrate( migrator.add_column(MyTable._meta.db_table, 'new_field', new_field), ) ``` , I get this error: ``` peewee.ProgrammingError: relation "table_name" does not exist ``` How can I tell the migrator that it should alter the table `table_name ` in the schema `my_schema `?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1353/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/1353/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1352
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1352/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1352/comments
https://api.github.com/repos/coleifer/peewee/issues/1352/events
https://github.com/coleifer/peewee/pull/1352
258,875,037
MDExOlB1bGxSZXF1ZXN0MTQxODkwMDY3
1,352
Allow releasing of stale connections back to pool.
{ "login": "sebastienvercammen", "id": 4874269, "node_id": "MDQ6VXNlcjQ4NzQyNjk=", "avatar_url": "https://avatars.githubusercontent.com/u/4874269?v=4", "gravatar_id": "", "url": "https://api.github.com/users/sebastienvercammen", "html_url": "https://github.com/sebastienvercammen", "followers_url": "https://api.github.com/users/sebastienvercammen/followers", "following_url": "https://api.github.com/users/sebastienvercammen/following{/other_user}", "gists_url": "https://api.github.com/users/sebastienvercammen/gists{/gist_id}", "starred_url": "https://api.github.com/users/sebastienvercammen/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/sebastienvercammen/subscriptions", "organizations_url": "https://api.github.com/users/sebastienvercammen/orgs", "repos_url": "https://api.github.com/users/sebastienvercammen/repos", "events_url": "https://api.github.com/users/sebastienvercammen/events{/privacy}", "received_events_url": "https://api.github.com/users/sebastienvercammen/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I'm not sure how a connection would still be busy, since peewee will block until the query is finished. Furthermore, connections aren't returned to the pool until you call `close()` on them.\r\n\r\nIf you don't wish for connections to be marked stale, you can also modify the `stale_timeout` parameter (which, by default, is not set).", "@coleifer We've restructured the original application that brought us to this use case, but I submitted the PR in case there's a use for releasing connections to the pool rather than closing them.\r\n\r\nYou're correct that peewee blocks for queries, but I was thinking about what would happen if a different thread went through the connections and found one that passed `stale_timeout` while its original thread was still waiting for a response.", "The connection wouldn't be available to another thread, as it would be \"checked out\" by the connection that was using it. There's a lock around connect/close, so no race condition either.\r\n\r\nConnections are released to the pool to be re-used when you call close() in the application. The pool itself will then close the connection if it is unusable or stale (if you've set up a stale timeout).", "@coleifer I seem to be overlooking the locks around connect/close in `PooledDatabase`, could you link me to it?", "They're in peewee's `Database` object.", "@coleifer That makes an awful lot more sense, thanks for clarifying. If you see no use for the PR (which no longer fits our own use case), feel free to close it.\r\n\r\nWith peewee blocking and waiting for responses, there might be a use case for someone that wants to use `stale_timeout` as a soft \"release to pool\" timeout that would assume the author didn't explicitly call close.", "Glad to help" ]
2017-09-19T16:00:01
2017-09-19T20:16:27
2017-09-19T20:16:18
NONE
null
Fine-grained control over the connection pool in non-web contexts can become more frustrating with the lightweight implementation because it's not implemented in peewee's core (e.g. after finishing a query, the connection isn't auto-released back to the pool), and in some structures context managers or decorators aren't desirable (requiring global access to the database's instance). Adding this (very simple) option allows us to release connections back to the pool when they are stale rather than closing them entirely. This lets the user decide on how to manage what peewee considers stale connections. There is one downside: the connection pool doesn't/can't know whether the query has finished so it's possible it will release busy connections back to the pool. I hope this PR can serve as a discussion board for a better solution, because calling `Model._meta.database.close()` after every query or needing global access to the database's instance is not ideal.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1352/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/1352/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1352", "html_url": "https://github.com/coleifer/peewee/pull/1352", "diff_url": "https://github.com/coleifer/peewee/pull/1352.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1352.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1351
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1351/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1351/comments
https://api.github.com/repos/coleifer/peewee/issues/1351/events
https://github.com/coleifer/peewee/issues/1351
258,003,252
MDU6SXNzdWUyNTgwMDMyNTI=
1,351
order_by didn't work
{ "login": "EverCurse", "id": 12572050, "node_id": "MDQ6VXNlcjEyNTcyMDUw", "avatar_url": "https://avatars.githubusercontent.com/u/12572050?v=4", "gravatar_id": "", "url": "https://api.github.com/users/EverCurse", "html_url": "https://github.com/EverCurse", "followers_url": "https://api.github.com/users/EverCurse/followers", "following_url": "https://api.github.com/users/EverCurse/following{/other_user}", "gists_url": "https://api.github.com/users/EverCurse/gists{/gist_id}", "starred_url": "https://api.github.com/users/EverCurse/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/EverCurse/subscriptions", "organizations_url": "https://api.github.com/users/EverCurse/orgs", "repos_url": "https://api.github.com/users/EverCurse/repos", "events_url": "https://api.github.com/users/EverCurse/events{/privacy}", "received_events_url": "https://api.github.com/users/EverCurse/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "it is my fault ,my code logic is error , thanks for peewee" ]
2017-09-15T11:00:42
2017-09-15T11:09:43
2017-09-15T11:09:43
NONE
null
when i use peewee to order my result like this: `us = Users.select().order_by(Users.id.desc())` i find desc didn't work, so i use `us = Users.select().order_by(Users.id.asc())` the result is same as desc , so why desc didn;t work? thanks
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1351/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/1351/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1350
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1350/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1350/comments
https://api.github.com/repos/coleifer/peewee/issues/1350/events
https://github.com/coleifer/peewee/issues/1350
257,961,248
MDU6SXNzdWUyNTc5NjEyNDg=
1,350
How to force not to get primary key on insert action
{ "login": "soyking", "id": 3882738, "node_id": "MDQ6VXNlcjM4ODI3Mzg=", "avatar_url": "https://avatars.githubusercontent.com/u/3882738?v=4", "gravatar_id": "", "url": "https://api.github.com/users/soyking", "html_url": "https://github.com/soyking", "followers_url": "https://api.github.com/users/soyking/followers", "following_url": "https://api.github.com/users/soyking/following{/other_user}", "gists_url": "https://api.github.com/users/soyking/gists{/gist_id}", "starred_url": "https://api.github.com/users/soyking/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/soyking/subscriptions", "organizations_url": "https://api.github.com/users/soyking/orgs", "repos_url": "https://api.github.com/users/soyking/repos", "events_url": "https://api.github.com/users/soyking/events{/privacy}", "received_events_url": "https://api.github.com/users/soyking/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "So...you bring up a good point. In peewee 2.x it's not really possible using the existing APIs.\r\n\r\nIn the 3.x branch, you can now write:\r\n\r\n```python\r\nSomeModel.insert({SomeModel.field: 'value'}).returning(None)\r\n```", "@coleifer \r\n\r\nThanks for your response. It helps a lot.\r\n\r\nps. Is there any way to run raw query in 3.0 ? I didn't find the API actually.", "There is no more `RawQuery` in 3.0a. You can use `Database.execute_sql()` instead, which returns a cursor object." ]
2017-09-15T08:16:52
2017-09-21T16:18:58
2017-09-21T16:18:58
NONE
null
I use peewee as PostgreSQL orm. As I saw on [InsertQuery.execute](https://github.com/coleifer/peewee/blob/81091b87c8c4b4d3dc65fc63b985629cd70dfd3a/peewee.py#L3584), when `is_insert_returning` is set, peewee will use `RETURNING` to get primary key. Otherwise it will call `last_insert_id` which is implemented by `SELECT CURRVAL` in PostgreSQL. In my case, I use partition function on Postgres. So I will `RETURN NULL` when inserting a row, which means `RETURNING` won't work. And `SELECT CURRVAL` will fail as well. So I open this issue to make sure that whether there is a way to force not to get primary key after insert action. Thanks!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1350/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/1350/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1349
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1349/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1349/comments
https://api.github.com/repos/coleifer/peewee/issues/1349/events
https://github.com/coleifer/peewee/issues/1349
257,688,613
MDU6SXNzdWUyNTc2ODg2MTM=
1,349
Unnecessary parentheses in the produced SQL
{ "login": "tuukkamustonen", "id": 94327, "node_id": "MDQ6VXNlcjk0MzI3", "avatar_url": "https://avatars.githubusercontent.com/u/94327?v=4", "gravatar_id": "", "url": "https://api.github.com/users/tuukkamustonen", "html_url": "https://github.com/tuukkamustonen", "followers_url": "https://api.github.com/users/tuukkamustonen/followers", "following_url": "https://api.github.com/users/tuukkamustonen/following{/other_user}", "gists_url": "https://api.github.com/users/tuukkamustonen/gists{/gist_id}", "starred_url": "https://api.github.com/users/tuukkamustonen/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/tuukkamustonen/subscriptions", "organizations_url": "https://api.github.com/users/tuukkamustonen/orgs", "repos_url": "https://api.github.com/users/tuukkamustonen/repos", "events_url": "https://api.github.com/users/tuukkamustonen/events{/privacy}", "received_events_url": "https://api.github.com/users/tuukkamustonen/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The parentheses are semantically correct, though to a human they look extraneous. It's completely acceptable." ]
2017-09-14T11:40:08
2017-09-14T13:42:52
2017-09-14T13:42:52
NONE
null
```python Foo.select().where((Foo.id == 1) | (Foo.id == 2) | (Foo.id == 3) | (Foo.id == 4)) ``` Produces SQL like: ```sql ... WHERE ((((\"t1\".\"id\" = 1) OR (\"t1\".\"id\" = 2)) OR (\"t1\".\"id\" = 3)) OR (\"t1\".\"id\" = 4)) ... ``` And so on. I don't know if the extra parentheses have impact on performance, but I would think so? Using `2.10.0` with postgres.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1349/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/1349/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1348
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1348/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1348/comments
https://api.github.com/repos/coleifer/peewee/issues/1348/events
https://github.com/coleifer/peewee/issues/1348
257,030,814
MDU6SXNzdWUyNTcwMzA4MTQ=
1,348
Delete() based on a dictionary instead of an Expression.
{ "login": "thxv3n0lvl", "id": 1503456, "node_id": "MDQ6VXNlcjE1MDM0NTY=", "avatar_url": "https://avatars.githubusercontent.com/u/1503456?v=4", "gravatar_id": "", "url": "https://api.github.com/users/thxv3n0lvl", "html_url": "https://github.com/thxv3n0lvl", "followers_url": "https://api.github.com/users/thxv3n0lvl/followers", "following_url": "https://api.github.com/users/thxv3n0lvl/following{/other_user}", "gists_url": "https://api.github.com/users/thxv3n0lvl/gists{/gist_id}", "starred_url": "https://api.github.com/users/thxv3n0lvl/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/thxv3n0lvl/subscriptions", "organizations_url": "https://api.github.com/users/thxv3n0lvl/orgs", "repos_url": "https://api.github.com/users/thxv3n0lvl/repos", "events_url": "https://api.github.com/users/thxv3n0lvl/events{/privacy}", "received_events_url": "https://api.github.com/users/thxv3n0lvl/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You can use:\r\n\r\n```python\r\nAdNetworkModel.delete().filter(**table_fields).execute()\r\n```\r\n\r\nIf you're working on serving advertisements, though, I probably shouldn't help you :)", "Thanks sir !" ]
2017-09-12T12:48:17
2017-09-12T15:13:34
2017-09-12T14:45:28
NONE
null
I have this dictionary `table_fields = {'entity_id': 9998777}` I can pass it to my own implementation of **get_or_create** by doing something like: ``` def get_or_create(table_fields): try: return AdNetworkModel.get(**table_fields).id except AdNetworkModel.DoesNotExist: return AdNetworkModel.create(**table_fields).id ``` My model looks like: ``` class AdNetworkModel(BaseModel): entity_id = peewee.CharField() class Meta: db_table = 'AD_NETWORK' ``` Until now all good, the get_or_create method works fine, but if I want to make a `delete()` it doesn't work, seems that I have to use an Expression which I wouldn't like to because I want to create my own dynamic delete based on a dictionary. Is this possible? ``` def delete(table_fields): AdNetworkModel.delete(**table_fields).execute() ``` The error that this code throws is: ``` {TypeError}delete() got an unexpected keyword argument 'entity_id' ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1348/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/1348/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1347
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1347/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1347/comments
https://api.github.com/repos/coleifer/peewee/issues/1347/events
https://github.com/coleifer/peewee/pull/1347
256,150,927
MDExOlB1bGxSZXF1ZXN0MTM5OTYyMTMy
1,347
Don't mark the column 'dirty' if there is no data change.
{ "login": "nad2000", "id": 177266, "node_id": "MDQ6VXNlcjE3NzI2Ng==", "avatar_url": "https://avatars.githubusercontent.com/u/177266?v=4", "gravatar_id": "", "url": "https://api.github.com/users/nad2000", "html_url": "https://github.com/nad2000", "followers_url": "https://api.github.com/users/nad2000/followers", "following_url": "https://api.github.com/users/nad2000/following{/other_user}", "gists_url": "https://api.github.com/users/nad2000/gists{/gist_id}", "starred_url": "https://api.github.com/users/nad2000/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/nad2000/subscriptions", "organizations_url": "https://api.github.com/users/nad2000/orgs", "repos_url": "https://api.github.com/users/nad2000/repos", "events_url": "https://api.github.com/users/nad2000/events{/privacy}", "received_events_url": "https://api.github.com/users/nad2000/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The tests have exploded.", "need more work on this one..." ]
2017-09-08T06:14:35
2017-10-27T09:10:04
2017-10-27T09:10:04
NONE
null
In order to reduce DB updates the columns should be marked if there was actually any data change...
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1347/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/1347/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1347", "html_url": "https://github.com/coleifer/peewee/pull/1347", "diff_url": "https://github.com/coleifer/peewee/pull/1347.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1347.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1346
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1346/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1346/comments
https://api.github.com/repos/coleifer/peewee/issues/1346/events
https://github.com/coleifer/peewee/issues/1346
255,062,064
MDU6SXNzdWUyNTUwNjIwNjQ=
1,346
Inserting a list of IntEnum members into ArrayField(IntegerField) fails
{ "login": "DragoonAethis", "id": 1546665, "node_id": "MDQ6VXNlcjE1NDY2NjU=", "avatar_url": "https://avatars.githubusercontent.com/u/1546665?v=4", "gravatar_id": "", "url": "https://api.github.com/users/DragoonAethis", "html_url": "https://github.com/DragoonAethis", "followers_url": "https://api.github.com/users/DragoonAethis/followers", "following_url": "https://api.github.com/users/DragoonAethis/following{/other_user}", "gists_url": "https://api.github.com/users/DragoonAethis/gists{/gist_id}", "starred_url": "https://api.github.com/users/DragoonAethis/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/DragoonAethis/subscriptions", "organizations_url": "https://api.github.com/users/DragoonAethis/orgs", "repos_url": "https://api.github.com/users/DragoonAethis/repos", "events_url": "https://api.github.com/users/DragoonAethis/events{/privacy}", "received_events_url": "https://api.github.com/users/DragoonAethis/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "peewee is handing the `IntEnum` members directly to psycopg2, so my sense is that the issue lies there. An alternative would be to subclass ArrayField and override the `db_value()` method, coercing each list item into an `int()`." ]
2017-09-04T14:44:35
2017-09-14T21:04:24
2017-09-14T21:04:24
NONE
null
Trying to use IntEnum members as values in `playhouse.postgres_ext.ArrayField(IntegerField)` will fail, since peewee wants to insert names of those values (for instance `"SomeEnum.example"`) instead of the actual values (eg. `1`). On PostgreSQL 9.6.4, peewee 2.10.1 and Python 3.6.2, this code: ```python from enum import IntEnum import peewee as pw from playhouse.postgres_ext import * # Behaves the same way in PostgresqlDatabase too. db = PostgresqlExtDatabase("exploding-db", user="user", password="nope", host="localhost") class Role(IntEnum): can_sign_in = 0 view_posts = 1 edit_posts = 2 delete_posts = 3 admin = 1000 class User(pw.Model): class Meta: database = db login = pw.TextField(unique=True) password = pw.TextField() # PasswordField IRL, but let's keep it simple roles = ArrayField(pw.IntegerField) db.drop_tables([User], safe=True) db.create_tables([User]) user = User(login="admin", password="test", roles=[Role.admin]) user.save() # Boom! ``` ...fails with: ``` Traceback (most recent call last): File "/somewhere/in/the/universe/peewee-boom.py", line 30, in <module> user.save() # Boom! File "/usr/lib/python3.6/site-packages/peewee.py", line 5108, in save pk_from_cursor = self.insert(**field_dict).execute() File "/usr/lib/python3.6/site-packages/peewee.py", line 3526, in execute cursor = self._execute() File "/usr/lib/python3.6/site-packages/peewee.py", line 2912, in _execute return self.database.execute_sql(sql, params, self.require_commit) File "/usr/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 390, in execute_sql self.commit() File "/usr/lib/python3.6/site-packages/peewee.py", line 3598, in __exit__ reraise(new_type, new_type(*exc_args), traceback) File "/usr/lib/python3.6/site-packages/peewee.py", line 135, in reraise raise value.with_traceback(tb) File "/usr/lib/python3.6/site-packages/playhouse/postgres_ext.py", line 383, in execute_sql cursor.execute(sql, params or ()) peewee.ProgrammingError: missing FROM-clause entry for table "role" LINE 1: ...assword", "roles") VALUES ('admin', 'test', ARRAY[Role.admin... ^ ``` Since [IntEnum](https://docs.python.org/3/library/enum.html#intenum) members are subclasses of ints, it should be possible to assign those members directly. Many other Python mechanisms treat them much like integers (so, say, `Role.admin == 1000` works as you'd expect), yet it doesn't in there. The workaround is to use `MyNeatEnum.member.value` instead of `MyNeatEnum.member`, but that gets a little bit repetitive. It'd be nice if this was handled automatically.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1346/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/1346/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1345
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1345/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1345/comments
https://api.github.com/repos/coleifer/peewee/issues/1345/events
https://github.com/coleifer/peewee/issues/1345
254,530,451
MDU6SXNzdWUyNTQ1MzA0NTE=
1,345
add truncate_table to doc
{ "login": "toshitanian", "id": 1647045, "node_id": "MDQ6VXNlcjE2NDcwNDU=", "avatar_url": "https://avatars.githubusercontent.com/u/1647045?v=4", "gravatar_id": "", "url": "https://api.github.com/users/toshitanian", "html_url": "https://github.com/toshitanian", "followers_url": "https://api.github.com/users/toshitanian/followers", "following_url": "https://api.github.com/users/toshitanian/following{/other_user}", "gists_url": "https://api.github.com/users/toshitanian/gists{/gist_id}", "starred_url": "https://api.github.com/users/toshitanian/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/toshitanian/subscriptions", "organizations_url": "https://api.github.com/users/toshitanian/orgs", "repos_url": "https://api.github.com/users/toshitanian/repos", "events_url": "https://api.github.com/users/toshitanian/events{/privacy}", "received_events_url": "https://api.github.com/users/toshitanian/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "That's true -- I will look at adding similar functionality to the 3.0a branch and will document it there, as Peewee will be moving to the 3.0 branch soon.", "Well, actually, I think I'm going to omit it from the 3.x branch for now, so will leave as-is. But thank you for letting me know." ]
2017-09-01T04:02:07
2019-04-12T22:20:52
2017-09-08T15:53:03
NONE
null
truncate_table is implemented on peewee, but not in doc. i hope it is written in doc. https://github.com/coleifer/peewee/pull/862/files
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1345/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/1345/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1344
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1344/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1344/comments
https://api.github.com/repos/coleifer/peewee/issues/1344/events
https://github.com/coleifer/peewee/issues/1344
253,803,728
MDU6SXNzdWUyNTM4MDM3Mjg=
1,344
pwiz creates incorrect code for composite foreign keys
{ "login": "fredrikchabot", "id": 4558741, "node_id": "MDQ6VXNlcjQ1NTg3NDE=", "avatar_url": "https://avatars.githubusercontent.com/u/4558741?v=4", "gravatar_id": "", "url": "https://api.github.com/users/fredrikchabot", "html_url": "https://github.com/fredrikchabot", "followers_url": "https://api.github.com/users/fredrikchabot/followers", "following_url": "https://api.github.com/users/fredrikchabot/following{/other_user}", "gists_url": "https://api.github.com/users/fredrikchabot/gists{/gist_id}", "starred_url": "https://api.github.com/users/fredrikchabot/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/fredrikchabot/subscriptions", "organizations_url": "https://api.github.com/users/fredrikchabot/orgs", "repos_url": "https://api.github.com/users/fredrikchabot/repos", "events_url": "https://api.github.com/users/fredrikchabot/events{/privacy}", "received_events_url": "https://api.github.com/users/fredrikchabot/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee does not support foreign keys to composite primary keys using any defined APIs.", "Edited issue to add syntax highlighting and proper formatting." ]
2017-08-29T21:04:01
2017-09-14T20:55:30
2017-09-14T20:55:30
NONE
null
Given this (PostgreSQL): ```sql CREATE TABLE tablea ( keyparta character varying(4) NOT NULL, keypartb integer NOT NULL, whatever character varying(20) ); CREATE TABLE tableb ( keyparta character varying(4) NOT NULL, keypartb integer NOT NULL, keypartc character varying(16) NOT NULL, whatever character varying(12) ); ALTER TABLE tablea ADD CONSTRAINT tablea_primary PRIMARY KEY (keyparta, keypartb); ALTER TABLE tableb ADD CONSTRAINT tableb_primary PRIMARY KEY (keyparta, keypartb, keypartc); ALTER TABLE tableb ADD CONSTRAINT tablea_keyparta_keypartb FOREIGN KEY (keyparta, keypartb) REFERENCES tablea(keyparta, keypartb); ``` pwiz creates a correct Tablea class, and a nonfunctioning Tableb class. ```python class Tableb(BaseModel): keyparta = ForeignKeyField(db_column='keyparta', rel_model=Tablea, related_name='tablea_keyparta_set', to_field='keypartb') .... ``` I wouldn't know how to express this schema either but having part of a foreign key pointing at a different part of it in the target table definitely doesn't work. Fredrik
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1344/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/1344/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1343
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1343/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1343/comments
https://api.github.com/repos/coleifer/peewee/issues/1343/events
https://github.com/coleifer/peewee/issues/1343
253,769,968
MDU6SXNzdWUyNTM3Njk5Njg=
1,343
peewee, flask and python3.6
{ "login": "noxizcm", "id": 15570550, "node_id": "MDQ6VXNlcjE1NTcwNTUw", "avatar_url": "https://avatars.githubusercontent.com/u/15570550?v=4", "gravatar_id": "", "url": "https://api.github.com/users/noxizcm", "html_url": "https://github.com/noxizcm", "followers_url": "https://api.github.com/users/noxizcm/followers", "following_url": "https://api.github.com/users/noxizcm/following{/other_user}", "gists_url": "https://api.github.com/users/noxizcm/gists{/gist_id}", "starred_url": "https://api.github.com/users/noxizcm/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/noxizcm/subscriptions", "organizations_url": "https://api.github.com/users/noxizcm/orgs", "repos_url": "https://api.github.com/users/noxizcm/repos", "events_url": "https://api.github.com/users/noxizcm/events{/privacy}", "received_events_url": "https://api.github.com/users/noxizcm/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "You need the standard library sqlite3 installed at the very least.", "Is there a way to avoid using sqlite3 all together?\r\nOr is sqlite3 a peer dependency of peewee?\r\n\r\nI'm encountering the same error on AWS Lambda. In my `models.py` I have the following defined:\r\n\r\n```\r\nfrom peewee import *\r\nfrom playhouse.db_url import connect\r\n\r\ndb = connect(os.environ.get('DATABASE_URL'))\r\n\r\nclass BaseModel(Model):\r\n class Meta:\r\n database = db\r\n\r\n# more models\r\n# ...\r\n```\r\n\r\nAnd when the lambda is executed, I get the following:\r\n\r\n```\r\nSTART RequestId: ... Version: $LATEST\r\nmodule initialization error: 'NoneType' object has no attribute 'sqlite_version_info'\r\n```", "What version of Peewee are you using? Could you share the full traceback? It seems that this shouldn't occur in the latest 2.x code:\r\n\r\nhttps://github.com/coleifer/peewee/blob/master/playhouse/sqlite_ext.py#L70-L73", "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" ]
2017-08-29T19:04:13
2017-10-08T16:22:54
2017-09-08T20:39:58
NONE
null
`sqlite3_lib_version = sqlite3.sqlite_version_info AttributeError: 'NoneType' object has no attribute 'sqlite_version_info'` from playhouse/berkeleydb.py how to fix it?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1343/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/1343/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1342
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1342/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1342/comments
https://api.github.com/repos/coleifer/peewee/issues/1342/events
https://github.com/coleifer/peewee/pull/1342
253,127,143
MDExOlB1bGxSZXF1ZXN0MTM3ODE0MjI2
1,342
Add --ssl option to pwiz
{ "login": "mgalvey", "id": 476468, "node_id": "MDQ6VXNlcjQ3NjQ2OA==", "avatar_url": "https://avatars.githubusercontent.com/u/476468?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mgalvey", "html_url": "https://github.com/mgalvey", "followers_url": "https://api.github.com/users/mgalvey/followers", "following_url": "https://api.github.com/users/mgalvey/following{/other_user}", "gists_url": "https://api.github.com/users/mgalvey/gists{/gist_id}", "starred_url": "https://api.github.com/users/mgalvey/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mgalvey/subscriptions", "organizations_url": "https://api.github.com/users/mgalvey/orgs", "repos_url": "https://api.github.com/users/mgalvey/repos", "events_url": "https://api.github.com/users/mgalvey/events{/privacy}", "received_events_url": "https://api.github.com/users/mgalvey/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Going to pass on this, but thank you.", "Is there anything that would make this or a feature like it suitable for inclusion in pwiz, or is this use case just something you're not interested in supporting?", "In 5...6 years you're the only person who's requested it :)", "@coleifer I guess I should say that we really need this. I'm not sure how we can use peewee in a anything with even mildly sensitive data without SSL. Basically, it's for the exact reason that @mgalvey was saying.\r\n\r\nIs this something you'd consider adding in for MySQL?" ]
2017-08-26T22:30:40
2019-06-18T09:20:10
2017-09-08T20:55:56
NONE
null
Refs #1336 Tested locally with both supported mysql drivers and didn't run into any problems. DID NOT test that psycopg tries SSL by default, but the docs for the client library that psycopg uses say that it does: https://www.postgresql.org/docs/9.1/static/libpq-ssl.html. From that page: > The default value for sslmode is prefer. This enables only the most simple ssl mode (with no CA verification), but it at least gets you around the problem of a server configured only to allow secure connections.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1342/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/1342/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1342", "html_url": "https://github.com/coleifer/peewee/pull/1342", "diff_url": "https://github.com/coleifer/peewee/pull/1342.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1342.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1341
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1341/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1341/comments
https://api.github.com/repos/coleifer/peewee/issues/1341/events
https://github.com/coleifer/peewee/issues/1341
253,093,921
MDU6SXNzdWUyNTMwOTM5MjE=
1,341
Filtering by TimestampField in Postgres
{ "login": "Alexeyisme", "id": 20242028, "node_id": "MDQ6VXNlcjIwMjQyMDI4", "avatar_url": "https://avatars.githubusercontent.com/u/20242028?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Alexeyisme", "html_url": "https://github.com/Alexeyisme", "followers_url": "https://api.github.com/users/Alexeyisme/followers", "following_url": "https://api.github.com/users/Alexeyisme/following{/other_user}", "gists_url": "https://api.github.com/users/Alexeyisme/gists{/gist_id}", "starred_url": "https://api.github.com/users/Alexeyisme/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Alexeyisme/subscriptions", "organizations_url": "https://api.github.com/users/Alexeyisme/orgs", "repos_url": "https://api.github.com/users/Alexeyisme/repos", "events_url": "https://api.github.com/users/Alexeyisme/events{/privacy}", "received_events_url": "https://api.github.com/users/Alexeyisme/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Solved. [Docs](http://docs.peewee-orm.com/en/latest/peewee/api.html?highlight=trunc#Database.truncate_date).\r\n```\r\ntoday_events = events.select().where(fn.date_trunc('day', fed_events.created_at) == datetime.date.today())\r\n```" ]
2017-08-26T13:48:25
2017-08-26T14:17:15
2017-08-26T14:17:14
NONE
null
Hello! I'm trying to filter queryset I got from remote Postgres DB by TimestampField, and can't find out the timestamp format to cast. I tried: `today_events = events.select().where(fed_events.created_at > '2017-08-25 00:00:00')` `today_events = events.filter(fed_events.created_at > '2017-08-25 00:00:00')` `today_events = events.filter(fed_events.created_at > 1503604800.0)` Also tried datetimes. I get errors like "You may need to cast the value explicitly". Do I miss something? Best Regards, Alexey
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1341/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/1341/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1340
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1340/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1340/comments
https://api.github.com/repos/coleifer/peewee/issues/1340/events
https://github.com/coleifer/peewee/pull/1340
253,071,133
MDExOlB1bGxSZXF1ZXN0MTM3Nzg5MjAz
1,340
Use LooseVersion for version comparisons.
{ "login": "robertwb", "id": 486017, "node_id": "MDQ6VXNlcjQ4NjAxNw==", "avatar_url": "https://avatars.githubusercontent.com/u/486017?v=4", "gravatar_id": "", "url": "https://api.github.com/users/robertwb", "html_url": "https://github.com/robertwb", "followers_url": "https://api.github.com/users/robertwb/followers", "following_url": "https://api.github.com/users/robertwb/following{/other_user}", "gists_url": "https://api.github.com/users/robertwb/gists{/gist_id}", "starred_url": "https://api.github.com/users/robertwb/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/robertwb/subscriptions", "organizations_url": "https://api.github.com/users/robertwb/orgs", "repos_url": "https://api.github.com/users/robertwb/repos", "events_url": "https://api.github.com/users/robertwb/events{/privacy}", "received_events_url": "https://api.github.com/users/robertwb/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[]
2017-08-26T07:29:53
2017-09-08T20:52:22
2017-09-08T20:52:22
CONTRIBUTOR
null
StrictVersion doesn't understand https://www.python.org/dev/peps/pep-0440/ , in particular release candidate numbers.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1340/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/1340/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1340", "html_url": "https://github.com/coleifer/peewee/pull/1340", "diff_url": "https://github.com/coleifer/peewee/pull/1340.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1340.patch", "merged_at": "2017-09-08T20:52:22" }
https://api.github.com/repos/coleifer/peewee/issues/1339
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1339/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1339/comments
https://api.github.com/repos/coleifer/peewee/issues/1339/events
https://github.com/coleifer/peewee/issues/1339
252,832,459
MDU6SXNzdWUyNTI4MzI0NTk=
1,339
full text postgres search crashes with more than one word
{ "login": "wilsonrocks", "id": 25229549, "node_id": "MDQ6VXNlcjI1MjI5NTQ5", "avatar_url": "https://avatars.githubusercontent.com/u/25229549?v=4", "gravatar_id": "", "url": "https://api.github.com/users/wilsonrocks", "html_url": "https://github.com/wilsonrocks", "followers_url": "https://api.github.com/users/wilsonrocks/followers", "following_url": "https://api.github.com/users/wilsonrocks/following{/other_user}", "gists_url": "https://api.github.com/users/wilsonrocks/gists{/gist_id}", "starred_url": "https://api.github.com/users/wilsonrocks/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/wilsonrocks/subscriptions", "organizations_url": "https://api.github.com/users/wilsonrocks/orgs", "repos_url": "https://api.github.com/users/wilsonrocks/repos", "events_url": "https://api.github.com/users/wilsonrocks/events{/privacy}", "received_events_url": "https://api.github.com/users/wilsonrocks/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee probably won't ever handle escaping search queries -- that should probably be done by the application as the needs may vary from app to app." ]
2017-08-25T08:32:35
2017-09-08T20:40:37
2017-09-08T20:40:37
NONE
null
This seems to be a postgres thing. I wrote some code to convert "multiple search terms! with punctuation." to "multiple & search & terms & with & punctuation" which doesn't crash it. Would this be useful in peewee, perhaps in the Match function?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1339/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/1339/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1338
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1338/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1338/comments
https://api.github.com/repos/coleifer/peewee/issues/1338/events
https://github.com/coleifer/peewee/issues/1338
252,541,394
MDU6SXNzdWUyNTI1NDEzOTQ=
1,338
Shouldn't ensure_join unfold aliases?
{ "login": "insolite", "id": 1101526, "node_id": "MDQ6VXNlcjExMDE1MjY=", "avatar_url": "https://avatars.githubusercontent.com/u/1101526?v=4", "gravatar_id": "", "url": "https://api.github.com/users/insolite", "html_url": "https://github.com/insolite", "followers_url": "https://api.github.com/users/insolite/followers", "following_url": "https://api.github.com/users/insolite/following{/other_user}", "gists_url": "https://api.github.com/users/insolite/gists{/gist_id}", "starred_url": "https://api.github.com/users/insolite/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/insolite/subscriptions", "organizations_url": "https://api.github.com/users/insolite/orgs", "repos_url": "https://api.github.com/users/insolite/repos", "events_url": "https://api.github.com/users/insolite/events{/privacy}", "received_events_url": "https://api.github.com/users/insolite/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Just realized that `filter` is actually deprecated, so I guess there no plans for it. Anyway `ensure_join` is also used inside `SelectQuery.annotate` so maybe it still makes sense.", "Hi, interesting I hadn't thought about this issue. You're correct as far as filter being deprecated, but it's still probably worth resolving this in some fashion. I would point out that filter supports a subset of the functionality of where, so if filter works there is a solution using where.", "06860a0a7619ffd3d0f80cbb81ce7e66ab632cb5 in the 3.0a branch fixes this issue. It also supports the use of the alias assigned to a model as a portion of the lookup:\r\n\r\n```python\r\n# works as expected in 3.0a:\r\nUserAlias = User.alias('ua')\r\nquery = (Tweet\r\n .select(Tweet.content, UserAlias.username)\r\n .join(UserAlias)\r\n .filter(ua__username='foo')\r\n\r\nfor tweet in query:\r\n print tweet.user.username, tweet.content\r\n```" ]
2017-08-24T09:29:38
2017-08-25T04:02:25
2017-08-25T04:01:41
NONE
null
```python class Author(peewee.Model): name = peewee.CharField() class Book(peewee.Model): name = peewee.CharField() author = peewee.ForeignKeyField(Author) query = (Book .select(Book.name) .join(Author.alias(), peewee.JOIN_LEFT_OUTER) .filter(author__name='someone')) print(query.sql()[0]) ``` `ensure_join` call inside `filter` generates additional join on `author` table because of the `Author.alias()`. The compiled query looks like: ```sql SELECT "t1"."name" FROM "book" AS t1 LEFT OUTER JOIN "author" AS t2 ON ("t1"."author_id" = "t2"."id") INNER JOIN "author" AS t3 ON ("t1"."author_id" = "t3"."id") WHERE ("t3"."name" = ?) ``` So shouldn't `Query.ensure_join` consider model and it's alias as the same model and do not generate additional join (`t3`) or I'm missing something and it is necessary? P. S. I know that it can be solved using `where` (see code below), but I've provided simplified test case. In my real code I have to use `filter` anyway. So just interesting if it's going to be changed or I must write my own `filter`. ```python author_alias = Author.alias() query = (Book .select(Book.name) .join(author_alias, peewee.JOIN_LEFT_OUTER) .where(author_alias.name == 'someone')) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1338/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/1338/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1337
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1337/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1337/comments
https://api.github.com/repos/coleifer/peewee/issues/1337/events
https://github.com/coleifer/peewee/issues/1337
252,091,830
MDU6SXNzdWUyNTIwOTE4MzA=
1,337
Nested Join
{ "login": "juntatalor", "id": 8134632, "node_id": "MDQ6VXNlcjgxMzQ2MzI=", "avatar_url": "https://avatars.githubusercontent.com/u/8134632?v=4", "gravatar_id": "", "url": "https://api.github.com/users/juntatalor", "html_url": "https://github.com/juntatalor", "followers_url": "https://api.github.com/users/juntatalor/followers", "following_url": "https://api.github.com/users/juntatalor/following{/other_user}", "gists_url": "https://api.github.com/users/juntatalor/gists{/gist_id}", "starred_url": "https://api.github.com/users/juntatalor/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/juntatalor/subscriptions", "organizations_url": "https://api.github.com/users/juntatalor/orgs", "repos_url": "https://api.github.com/users/juntatalor/repos", "events_url": "https://api.github.com/users/juntatalor/events{/privacy}", "received_events_url": "https://api.github.com/users/juntatalor/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "What?! This is some next-level shit!\r\n\r\nCan you explain what, semantically, you're doing in the above query? Like...use tables with familiar names/concepts, e.g.\r\n\r\n```sql\r\nSELECT *\r\nFROM users AS t1\r\nLEFT OUTER JOIN notes AS t2\r\nINNER JOIN note_tags AS t3\r\n ON (t2.id = t3.note_id) ON (t1.id = t2.user_id)\r\n```\r\n\r\nI'm not even sure if the above makes sense...can you explain?", "https://stackoverflow.com/questions/10334608/nested-inner-join-vs-inner-join-vs-where-correctness-performance-clarity-for\r\n\r\nand\r\n\r\nhttp://michaeljswart.com/2012/09/when-i-use-nested-joins/", "The key idea is that peewee can do either 2 left joins on table **t1** or left join and inner join on table **t1**. The second variant is incorrect, because some rows are truncated (null values).\r\nThe first one is bad because 2 left joins cost much.\r\nDoing nested join performs inner join on t2 -> t3 and then left join with the result (less rows for nested loop operation is done faster)\r\nFinally i resolved this issue with doing a nested select query (despite it looks ugly).\r\nThanks for your ORM, it works great. Not every sql feature can be simply done with query builders, it's okay.", "Thanks for the explanation, that makes sense to me...interesting. I hadn't heard of doing such a thing, but yeah, makes sense I guess. I'm surprised that Postgres' query planner doesn't automatically optimize the naive LEFT/LEFT query, unless there's some semantic difference I'm not aware of...I suppose that there could be more result rows with the LEFT/LEFT than with the LEFT->INNER, so they're not exactly equivalent?", "One approach that may work using the existing APIs is to use a subquery, e.g.\r\n\r\n```python\r\nclass Employee(Model):\r\n name = TextField()\r\n\r\nclass OrgChart(Model):\r\n employee = ForeignKeyField(Employee, backref='bosses')\r\n boss = ForeignKeyField(Employee, backref='reports')\r\n class Meta:\r\n primary_key = CompositeKey('employee', 'boss')\r\n\r\n# Get employees and their boss.\r\nBoss = Employee.alias('boss')\r\nsubq = (OrgChart\r\n .select(Boss.name.alias('boss'), OrgChart.employee.alias('emp'))\r\n .join(Boss, on=(OrgChart.boss == Boss.id))\r\n .alias('subq'))\r\nquery = (Employee\r\n .select(Employee.name, subq.c.boss)\r\n .join(subq, JOIN.LEFT_OUTER,\r\n on=(Employee.id == subq.c.emp))\r\n .order_by(Employee.name))\r\n\r\nfor empname, bossname in query.tuples():\r\n print empname, '=>', bossname\r\n```", "Given that it is possible to accomplish the same with existing APIs (albeit using a different construction) I think I'll pass on trying to implement this... I'm not sure of what a good API would even be." ]
2017-08-22T21:15:37
2017-08-24T22:34:46
2017-08-24T22:34:46
NONE
null
Cannot find a way to do nested join, like: SELECT * FROM t1 LEFT OUTER JOIN t2 INNER JOIN t3 ON (t2.x_id = t3.id) ON (t1.y_id = t2.id) This query is much faster than two left joins for my particular task (PostgreSQL). Subquery looks ugly.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1337/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/1337/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1336
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1336/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1336/comments
https://api.github.com/repos/coleifer/peewee/issues/1336/events
https://github.com/coleifer/peewee/issues/1336
252,034,289
MDU6SXNzdWUyNTIwMzQyODk=
1,336
Suport SSL connections
{ "login": "mgalvey", "id": 476468, "node_id": "MDQ6VXNlcjQ3NjQ2OA==", "avatar_url": "https://avatars.githubusercontent.com/u/476468?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mgalvey", "html_url": "https://github.com/mgalvey", "followers_url": "https://api.github.com/users/mgalvey/followers", "following_url": "https://api.github.com/users/mgalvey/following{/other_user}", "gists_url": "https://api.github.com/users/mgalvey/gists{/gist_id}", "starred_url": "https://api.github.com/users/mgalvey/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mgalvey/subscriptions", "organizations_url": "https://api.github.com/users/mgalvey/orgs", "repos_url": "https://api.github.com/users/mgalvey/repos", "events_url": "https://api.github.com/users/mgalvey/events{/privacy}", "received_events_url": "https://api.github.com/users/mgalvey/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Peewee operates at a higher-level than the database drivers, so any SSL support would need to be implemented at the `pymysql`/`psycopg2` layer instead of Peewee.", "It is implemented in PyMySQL (http://pymysql.readthedocs.io/en/latest/modules/connections.html?highlight=ssl), but I'm not sure how I would make use of that in pwiz.\r\n\r\nI haven't tested, but it seems like the recommended way to do this in peewee proper would be to use connect_kwargs on instantiation of a Database object, correct?", "You would just:\r\n\r\n db = MySQLDatabase('db_name', ssl='whatever')\r\n\r\nAny keyword arguments that peewee doesn't recognize are passed back to the db driver, so `ssl` would get passed to pymysql in this case.", "Right. That makes sense for peewee proper and is in line with what I expected I'd have to do from your initial response.\r\n\r\nIs there any way to do something similar with pwiz, or is that just something I'd have to make modifications to the code for? It looks from the current pwiz code like there's not an obvious way to get arbitrary options into the database constructor. Would a PR to add a convenience flag to pwiz (--ssl, for instance) be welcome?", "Oh, I understand now what you're asking -- you may need to make some changes to pwiz or just write a wrapper script to do the same thing pwiz does.", "@coleifer Also mentioning in this Issue. With the sensitive data we're dealing with and the MySQL DB that enforces SSL connections, we need a way to connect.\r\n\r\nSomething you would consider supporting?", "Same advise still applies:\r\n\r\n> you may need to make some changes to pwiz or just write a wrapper script to do the same thing pwiz does.\r\n\r\nWhat is with putting SSL on MySQL? Is your db exposed to the internet or something? Clustered across multiple data-centers?", "So I'm not quite sure how pwiz works yet. Still working through the code and looking.\r\n\r\nBut to answer your question first, yeah, the DB is exposed to the internet. It's not clustered across multiple datacenters or anything but it does need to be accessed by multiple parties over the public internet.\r\n\r\nAzure even has a management portal setting in the Azure MySQL server product that defaults to enforcing it. It seems like it's an important enough use case for them to care about it and even go so far as to default to it for all customers.\r\n\r\n![image](https://user-images.githubusercontent.com/29720335/59741577-36f2c780-9220-11e9-9ca0-83835cea20a0.png)\r\n", "> But to answer your question first, yeah, the DB is exposed to the internet. It's not clustered across multiple datacenters or anything but it does need to be accessed by multiple parties over the public internet.\r\n\r\nWhat in the fuck. If its in Azure, presumably you have it only visible on your virtual LAN, I hope (pray)? Or that at the very least you're not handling any important data...", "Nope, it's exposed to the internet internet. It's not that uncommon of a use case. Azure has other protections of course like only allowing source IPs that are explicitly specified by the user to connect. By default SSL is enforced and no source IPs are allowed through.\r\n\r\nThere's even a dev page to describe how to do it right.\r\n\r\nhttps://docs.microsoft.com/en-us/azure/mysql/concepts-firewall-rules\r\n\r\nNot everyone has a corporate VPN that they can hide all this behind and for not-so-sensitive data these protections are enough but that doesn't mean you want snooping obviously.\r\n\r\nIn our particular use case at this very moment it's just development so all IPs are known and the data isn't particularly sensitive but that doesn't mean I'd want people listening in. SSL in everything I'd think should be standard. Even within a vlan I'd use it." ]
2017-08-22T17:36:44
2019-06-20T01:56:50
2017-08-22T22:15:10
NONE
null
At present, it appears that peewee / pwiz has no support for connecting to MySQL or Postgres using SSL. Such a feature would be useful in environments where the database is configured to only allow encrypted connections. I'm not as familiar with Postgres, but I know that at least two modes should be available for MySQL: require SSL, and require SSL + verify CA.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1336/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/1336/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1335
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1335/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1335/comments
https://api.github.com/repos/coleifer/peewee/issues/1335/events
https://github.com/coleifer/peewee/issues/1335
251,935,888
MDU6SXNzdWUyNTE5MzU4ODg=
1,335
primary_key=False is not inheritable
{ "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
[ "This is working correctly in 3.0a -- I'm not inclined to change it in the 2.x branch, despite the documentation being somewhat confusing.\r\n\r\n023037adf3d87127969c71bc95e6e6e070590873" ]
2017-08-22T12:13:03
2017-08-24T00:21:28
2017-08-24T00:21:28
CONTRIBUTOR
null
[This table](http://docs.peewee-orm.com/en/latest/peewee/models.html#model-options-and-table-metadata) says that `primary_key` is an inheritable meta field. But it doesn't seem so, at least not when I set `primary_key=False` on a parent model and expect a child class to get the same. If it's a bug, I think it should be fixed. If it's supposed to be this way, I think it's worth mentioning in documentation.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1335/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/1335/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1334
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1334/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1334/comments
https://api.github.com/repos/coleifer/peewee/issues/1334/events
https://github.com/coleifer/peewee/issues/1334
251,817,819
MDU6SXNzdWUyNTE4MTc4MTk=
1,334
How much efficiency has been raised?
{ "login": "yanghg-basefx", "id": 29534214, "node_id": "MDQ6VXNlcjI5NTM0MjE0", "avatar_url": "https://avatars.githubusercontent.com/u/29534214?v=4", "gravatar_id": "", "url": "https://api.github.com/users/yanghg-basefx", "html_url": "https://github.com/yanghg-basefx", "followers_url": "https://api.github.com/users/yanghg-basefx/followers", "following_url": "https://api.github.com/users/yanghg-basefx/following{/other_user}", "gists_url": "https://api.github.com/users/yanghg-basefx/gists{/gist_id}", "starred_url": "https://api.github.com/users/yanghg-basefx/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/yanghg-basefx/subscriptions", "organizations_url": "https://api.github.com/users/yanghg-basefx/orgs", "repos_url": "https://api.github.com/users/yanghg-basefx/repos", "events_url": "https://api.github.com/users/yanghg-basefx/events{/privacy}", "received_events_url": "https://api.github.com/users/yanghg-basefx/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "So, the peewee 2.x speedups module should help noticeably with:\r\n\r\n* Iterating over large result sets for simple selects (no joins) or when the return row type is `dict` or `tuple` (`.dicts()` or `.tuples()`).\r\n* Resolving dependencies among a large number of models.\r\n\r\nIt's a pretty narrow range, and honestly, the gains are not that huge. With SQLite in-memory database containing 100K rows, iterating through them all yields:\r\n\r\n- select models 5.412\r\n- select dicts 4.114\r\n- select tuples 4.231\r\n\r\nAnd with speedups:\r\n\r\n- select models 5.229\r\n- select dicts 3.743\r\n- select tuples 3.718\r\n\r\nIn the 3.x branch, there is no longer a \"speedups\" module simply because I didn't feel the maintenance burden of the additional code justified the tiny improvement. It was more of an experiment than anything else, I suppose.\r\n\r\nTimings for 3.0a, just in case you were curious, are comparable to `master`:\r\n\r\n- select models 5.751\r\n- select dicts 4.268\r\n- select tuples 4.271", "Here's the quick little script I put together to generate these numbers: https://gist.github.com/coleifer/7050c85d9e48dbe1307d7d648f7628a7", "Ah, I got it, thanks." ]
2017-08-22T02:09:49
2017-08-22T04:11:17
2017-08-22T02:57:47
NONE
null
I compiled _speedups.pyx at centos7, then try to fetch a whole table from MySQL database. I'm sure the speedups module was imported successfully, but it spent the same time as normal module. Does it work?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1334/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/1334/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1333
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1333/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1333/comments
https://api.github.com/repos/coleifer/peewee/issues/1333/events
https://github.com/coleifer/peewee/issues/1333
251,420,977
MDU6SXNzdWUyNTE0MjA5Nzc=
1,333
How to integrate peewee and Flask-login
{ "login": "noxizcm", "id": 15570550, "node_id": "MDQ6VXNlcjE1NTcwNTUw", "avatar_url": "https://avatars.githubusercontent.com/u/15570550?v=4", "gravatar_id": "", "url": "https://api.github.com/users/noxizcm", "html_url": "https://github.com/noxizcm", "followers_url": "https://api.github.com/users/noxizcm/followers", "following_url": "https://api.github.com/users/noxizcm/following{/other_user}", "gists_url": "https://api.github.com/users/noxizcm/gists{/gist_id}", "starred_url": "https://api.github.com/users/noxizcm/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/noxizcm/subscriptions", "organizations_url": "https://api.github.com/users/noxizcm/orgs", "repos_url": "https://api.github.com/users/noxizcm/repos", "events_url": "https://api.github.com/users/noxizcm/events{/privacy}", "received_events_url": "https://api.github.com/users/noxizcm/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "I think you have to read that https://flask-login.readthedocs.io/en/latest/#flask_login.LoginManager.user_loader\r\nAnd implement methods in your User-model that were discussed flask-login.", "Sorry, please direct this question to a more appropriate forum." ]
2017-08-19T12:09:11
2017-08-22T03:52:33
2017-08-22T03:52:32
NONE
null
D! i am trying to use peewee and flask-login but wen create and user loader i have this error ` @login_manager.user_loader() TypeError: user_loader() missing 1 required positional argument: 'callback'` i knew that peewee have get_id() method but how to use it?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1333/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/1333/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1332
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1332/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1332/comments
https://api.github.com/repos/coleifer/peewee/issues/1332/events
https://github.com/coleifer/peewee/issues/1332
251,320,576
MDU6SXNzdWUyNTEzMjA1NzY=
1,332
Is it possible to get a count of a grouped field?
{ "login": "iancullinane", "id": 3598675, "node_id": "MDQ6VXNlcjM1OTg2NzU=", "avatar_url": "https://avatars.githubusercontent.com/u/3598675?v=4", "gravatar_id": "", "url": "https://api.github.com/users/iancullinane", "html_url": "https://github.com/iancullinane", "followers_url": "https://api.github.com/users/iancullinane/followers", "following_url": "https://api.github.com/users/iancullinane/following{/other_user}", "gists_url": "https://api.github.com/users/iancullinane/gists{/gist_id}", "starred_url": "https://api.github.com/users/iancullinane/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/iancullinane/subscriptions", "organizations_url": "https://api.github.com/users/iancullinane/orgs", "repos_url": "https://api.github.com/users/iancullinane/repos", "events_url": "https://api.github.com/users/iancullinane/events{/privacy}", "received_events_url": "https://api.github.com/users/iancullinane/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Well, you need to group by both title and field if you're selecting both (unless you use mysql, which allows shenanigans like this).\r\n\r\nIf you have a lot of people, this prints out the surnames and the count associated with each, e.g.:\r\n\r\n```python\r\nquery = Person.select(Person.last_name, fn.COUNT(Person.id).alias('ct')).group_by(Person.last_name)\r\nfor person in query:\r\n print person.last_name, person.ct\r\n```" ]
2017-08-18T18:14:31
2017-08-18T19:05:06
2017-08-18T19:05:06
NONE
null
I have the following MySQL query: `select Title, Field, count(*) as 'count' from model group by Title;` Which returns: `{ Title: 'Something', Field: 'Something Else', count: '5' } ` Where count is the number of occurrences of Title. I have been banging my head figuring out how to get this through peewee with no luck. Is this possible? The closest I have come sees the `Title` return overwrite the `Title` field so instead of 'Something' I get the count.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1332/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/1332/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1331
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1331/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1331/comments
https://api.github.com/repos/coleifer/peewee/issues/1331/events
https://github.com/coleifer/peewee/issues/1331
250,761,425
MDU6SXNzdWUyNTA3NjE0MjU=
1,331
Why use exec?
{ "login": "thomwiggers", "id": 974662, "node_id": "MDQ6VXNlcjk3NDY2Mg==", "avatar_url": "https://avatars.githubusercontent.com/u/974662?v=4", "gravatar_id": "", "url": "https://api.github.com/users/thomwiggers", "html_url": "https://github.com/thomwiggers", "followers_url": "https://api.github.com/users/thomwiggers/followers", "following_url": "https://api.github.com/users/thomwiggers/following{/other_user}", "gists_url": "https://api.github.com/users/thomwiggers/gists{/gist_id}", "starred_url": "https://api.github.com/users/thomwiggers/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/thomwiggers/subscriptions", "organizations_url": "https://api.github.com/users/thomwiggers/orgs", "repos_url": "https://api.github.com/users/thomwiggers/repos", "events_url": "https://api.github.com/users/thomwiggers/events{/privacy}", "received_events_url": "https://api.github.com/users/thomwiggers/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "because on python 3 `raise tp, value, tb` will raise `SyntaxError`, use `exec` to skip syntax check.", "Ah, TIL. Thanks" ]
2017-08-16T21:11:25
2017-08-17T09:29:15
2017-08-17T09:29:15
NONE
null
On this line you're using `exec` to define `reraise`. I don't understand why you just don't use `def` directly. Would you mind clearing this up for me? https://github.com/coleifer/peewee/blob/7beab7c60ca32477fb812eb768adc4ac458e5a57/peewee.py#L144
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1331/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/1331/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1330
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1330/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1330/comments
https://api.github.com/repos/coleifer/peewee/issues/1330/events
https://github.com/coleifer/peewee/issues/1330
250,695,285
MDU6SXNzdWUyNTA2OTUyODU=
1,330
Database.is_closed() returns incorrect value sometimes
{ "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
[ "How would moving that outside the block change things?", "if I am understanding the code correctly:\r\n\r\nCurrently if the call to `self._close(self._local.conn)` raises an Exception then `with self.exception_wrapper` will `__exit__` and `self._local.closed = True` will never be called.\r\n\r\nBy moving `self._local.closed = True` out of the `with` it should always get executed.", "The exception_wrapper simply wraps the exceptions raised by the database driver to a \"peewee\" equivalent exception. It doesn't suppress the exception. Thus you can catch a peewee.OperationalError rather than needing to catch both psycopg2 / sqlite3 if you were so inclined, e.g.", "Okay, then perhaps something like this:\r\n\r\n```python\r\ndef close(self):\r\n with self._conn_lock:\r\n if self.deferred:\r\n raise Exception('Error, database not properly initialized '\r\n 'before closing connection')\r\n try:\r\n with self.exception_wrapper:\r\n self._close(self._local.conn)\r\n finally:\r\n self._local.closed = True\r\n```", "Are you intending to catch the `InterfaceError` yourself and ignore it?", "b06a9b0" ]
2017-08-16T17:02:23
2017-08-17T21:27:07
2017-08-17T21:27:07
NONE
null
I sometimes get this: `psycopg2.InterfaceError: connection already closed` and can't seem to track it down. But I was able to determine that Database.is_closed() returns an incorrect value sometimes. I looked in peewee.py at the close() method of the Database class and would like to propose a small improvement: Currently: ``` with self.exception_wrapper: self._close(self._local.conn) self._local.closed = True # this line is inside the with ``` Proposed: ``` with self.exception_wrapper: self._close(self._local.conn) self._local.closed = True # move it outside the with (should it go back 1 or 2 levels??) ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1330/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/1330/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1329
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1329/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1329/comments
https://api.github.com/repos/coleifer/peewee/issues/1329/events
https://github.com/coleifer/peewee/issues/1329
250,576,641
MDU6SXNzdWUyNTA1NzY2NDE=
1,329
model_to_dict not working with generic foreign keys
{ "login": "hishamkaram", "id": 24391550, "node_id": "MDQ6VXNlcjI0MzkxNTUw", "avatar_url": "https://avatars.githubusercontent.com/u/24391550?v=4", "gravatar_id": "", "url": "https://api.github.com/users/hishamkaram", "html_url": "https://github.com/hishamkaram", "followers_url": "https://api.github.com/users/hishamkaram/followers", "following_url": "https://api.github.com/users/hishamkaram/following{/other_user}", "gists_url": "https://api.github.com/users/hishamkaram/gists{/gist_id}", "starred_url": "https://api.github.com/users/hishamkaram/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/hishamkaram/subscriptions", "organizations_url": "https://api.github.com/users/hishamkaram/orgs", "repos_url": "https://api.github.com/users/hishamkaram/repos", "events_url": "https://api.github.com/users/hishamkaram/events{/privacy}", "received_events_url": "https://api.github.com/users/hishamkaram/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "The `model_to_dict` accepts a parameter `extra_attrs` which you can use to do the lookup on the GFK object." ]
2017-08-16T10:13:26
2017-08-16T20:39:01
2017-08-16T20:39:01
NONE
null
I am trying to include tags in object dict to convert this data to json then use this data in api how can i achieve that?(if models_to_dict can include tags in dict) select query: `queryset = model.select()` Tag Model: ``` class Tag(BaseDateTime): tag = CharField() object_type = CharField(null=True) object_id = IntegerField(null=True) object = GFKField('object_type', 'object_id') ``` model_to_dict ``` result = [] for obj in queryset: print obj.tags result.append(model_to_dict( obj, recurse=True, backrefs=True)) ``` note: model create dynamically using : ``` def generate_XXXX_model(self): model_fields = { 'text': CharField(index=True), 'tags': ReverseGFK(Tag, 'object_type', 'object_id') } model = type(self.model_name, (BaseModel,), model_fields) model._meta.db_table = "XXXX_%s_XXXX" % self.table_name if not model.table_exists(): model.create_table() _XXXX_XXX_models_cache[self.table_name] = model return model ``` result sample: ``` [ { "username": "user3", "created": "2017-08-16T04:12:24.374450", "text": "api", "modified": "2017-08-16T04:12:24.374481", "feature_id": "11", "id": 2 }, { "username": "user2", "created": "2017-08-16T04:14:17.899443", "text": "api", "modified": "2017-08-16T04:14:17.899524", "feature_id": "13", "id": 3 }, { "username": "user1", "created": "2017-08-16T04:14:50.413285", "text": "api", "modified": "2017-08-16T04:14:50.413322", "feature_id": "16", "id": 4 } ] ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1329/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/1329/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1328
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1328/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1328/comments
https://api.github.com/repos/coleifer/peewee/issues/1328/events
https://github.com/coleifer/peewee/issues/1328
250,115,979
MDU6SXNzdWUyNTAxMTU5Nzk=
1,328
3.0a
{ "login": "ra-esmith", "id": 24212262, "node_id": "MDQ6VXNlcjI0MjEyMjYy", "avatar_url": "https://avatars.githubusercontent.com/u/24212262?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ra-esmith", "html_url": "https://github.com/ra-esmith", "followers_url": "https://api.github.com/users/ra-esmith/followers", "following_url": "https://api.github.com/users/ra-esmith/following{/other_user}", "gists_url": "https://api.github.com/users/ra-esmith/gists{/gist_id}", "starred_url": "https://api.github.com/users/ra-esmith/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ra-esmith/subscriptions", "organizations_url": "https://api.github.com/users/ra-esmith/orgs", "repos_url": "https://api.github.com/users/ra-esmith/repos", "events_url": "https://api.github.com/users/ra-esmith/events{/privacy}", "received_events_url": "https://api.github.com/users/ra-esmith/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Ahhh yeah, the new codebase is not compatible with wtfpeewee or flask-peewee at the moment.", "Hello,\n\nCool. When it is I will try an upgrade again.\n\nThanks!!! Super that you are doing this\n\nLater,\nEvan\n\nCharles Leifer wrote:\n>\n> Ahhh yeah, the new codebase is not compatible with wtfpeewee or \n> flask-peewee at the moment.\n>\n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly, view it on GitHub \n> <https://github.com/coleifer/peewee/issues/1328#issuecomment-322276891>, \n> or mute the thread \n> <https://github.com/notifications/unsubscribe-auth/AXFzJpUP3tH83OBL2rYszDALW5XK5aKYks5sYJeigaJpZM4O2vJa>.\n>\n\n", "This appears to still be an issue. Are there any noticeable blockers to this?", "I don't think so, I pushed wtf-peewee 3.0.0 which should work with Peewee 3.0.0+." ]
2017-08-14T18:36:54
2018-01-30T15:54:52
2017-10-02T20:38:55
NONE
null
Hello, Exciting to see an upgrade path. I thought I would try it out. I removed the 2.10 version of peewee and installed 3.0a Note, my app runs fine with 2.10.1, and I understand I may need to change some stuff to get to 3.0a. Just thought I would start the process. Thanks for the great product! pip uninstall peewee==2.10.1 pip install git+https://github.com/coleifer/[email protected] Ran into an error ... not sure what it is about, other than not there :-) Looks like 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:31:30 web.1 | from peewee import PrimaryKeyField 14:31:30 web.1 | ImportError: cannot import name PrimaryKeyField is the basic problem. 14:31:28 web.1 | [2017-08-14 14:31:28 -0400] [9756] [INFO] Starting gunicorn 19.7.1 14:31:28 web.1 | [2017-08-14 14:31:28 -0400] [9756] [INFO] Listening at: http://0.0.0.0:5000 (9756) 14:31:28 web.1 | [2017-08-14 14:31:28 -0400] [9756] [INFO] Using worker: gevent 14:31:28 web.1 | [2017-08-14 14:31:28 -0400] [9759] [INFO] Booting worker with pid: 9759 14:31:28 web.1 | [2017-08-14 14:31:28 -0400] [9761] [INFO] Booting worker with pid: 9761 14:31:29 web.1 | [2017-08-14 14:31:29 -0400] [9763] [INFO] Booting worker with pid: 9763 14:31:29 web.1 | [2017-08-14 14:31:29 -0400] [9764] [INFO] Booting worker with pid: 9764 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9761] [ERROR] Exception in worker process 14:31:30 web.1 | Traceback (most recent call last): 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:31:30 web.1 | worker.init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:31:30 web.1 | super(GeventWorker, self).init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:31:30 web.1 | self.load_wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:31:30 web.1 | self.wsgi = self.app.wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:31:30 web.1 | self.callable = self.load() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 14:31:30 web.1 | /gunicorn/app/wsgiapp.py", line 65, in load 14:31:30 web.1 | return self.load_wsgiapp() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:31:30 web.1 | return util.import_app(self.app_uri) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:31:30 web.1 | __import__(module) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/main.py", line 22, in <module> 14:31:30 web.1 | import xyzzy_admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/xyzzy_admin.py", line 9, in <module> 14:31:30 web.1 | from flask_peewee.admin import Admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2 14:31:30 web.1 | .7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:31:30 web.1 | from flask_peewee.filters import FilterForm 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:31:30 web.1 | from flask_peewee.forms import BaseModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:31:30 web.1 | from wtfpeewee.orm import ModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python. 14:31:30 web.1 | framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:31:30 web.1 | from peewee import PrimaryKeyField 14:31:30 web.1 | ImportError: cannot import name PrimaryKeyField 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9759] [ERROR] Exception in worker process 14:31:30 web.1 | Traceback (most recent call last): 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:31:30 web.1 | worker.init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:31:30 web.1 | super(GeventWorker, self).init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:31:30 web.1 | self.load_wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:31:30 web.1 | self.wsgi = self.app.wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:31:30 web.1 | self.callable = self.load() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 14:31:30 web.1 | /gunicorn/app/wsgiapp.py", line 65, in load 14:31:30 web.1 | return self.load_wsgiapp() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:31:30 web.1 | return util.import_app(self.app_uri) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:31:30 web.1 | __import__(module) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/main.py", line 22, in <module> 14:31:30 web.1 | import xyzzy_admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/xyzzy_admin.py", line 9, in <module> 14:31:30 web.1 | from flask_peewee.admin import Admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:31:30 web.1 | from flask_peewee.filters import FilterForm 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:31:30 web.1 | from flask_peewee.forms import BaseModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:31:30 web.1 | from wtfpeewee.orm import ModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:31:30 web.1 | from peewee import PrimaryKeyField 14:31:30 web.1 | ImportError: cannot import name PrimaryKeyField 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9759] [INFO] Worker exiting (pid: 9759) 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9761] [INFO] Worker exiting (pid: 9761) 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9763] [ERROR] Exception in worker process 14:31:30 web.1 | Traceback (most recent call last): 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:31:30 web.1 | worker.init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:31:30 web.1 | super(GeventWorker, self).init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:31:30 web.1 | self.load_wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:31:30 web.1 | self.wsgi = self.app.wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:31:30 web.1 | self.callable = self.load() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 14:31:30 web.1 | /gunicorn/app/wsgiapp.py", line 65, in load 14:31:30 web.1 | return self.load_wsgiapp() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:31:30 web.1 | return util.import_app(self.app_uri) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:31:30 web.1 | __import__(module) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/main.py", line 22, in <module> 14:31:30 web.1 | import xyzzy_admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/xyzzy_admin.py", line 9, in <module> 14:31:30 web.1 | from flask_peewee.admin import Admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2 14:31:30 web.1 | .7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:31:30 web.1 | from flask_peewee.filters import FilterForm 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:31:30 web.1 | from flask_peewee.forms import BaseModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:31:30 web.1 | from wtfpeewee.orm import ModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python. 14:31:30 web.1 | framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:31:30 web.1 | from peewee import PrimaryKeyField 14:31:30 web.1 | ImportError: cannot import name PrimaryKeyField 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9763] [INFO] Worker exiting (pid: 9763) 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9764] [ERROR] Exception in worker process 14:31:30 web.1 | Traceback (most recent call last): 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 14:31:30 web.1 | worker.init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 190, in init_process 14:31:30 web.1 | super(GeventWorker, self).init_process() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 14:31:30 web.1 | self.load_wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 14:31:30 web.1 | self.wsgi = self.app.wsgi() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 14:31:30 web.1 | self.callable = self.load() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 14:31:30 web.1 | return self.load_wsgiapp() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 14:31:30 web.1 | return util.import_app(self.app_uri) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 14:31:30 web.1 | __import__(module) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/main.py", line 22, in <module> 14:31:30 web.1 | import xyzzy_admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Users/anon/Desktop/ra/xyzzy-master/xyzzy_admin.py", line 9, in <module> 14:31:30 web.1 | from flask_peewee.admin import Admin 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/admin.py", line 19, in <module> 14:31:30 web.1 | from flask_peewee.filters import FilterForm 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/filters.py", line 5, in <module> 14:31:30 web.1 | from flask_peewee.forms import BaseModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/flask_peewee/forms.py", line 6, in <module> 14:31:30 web.1 | from wtfpeewee.orm import ModelConverter 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gevent/builtins.py", line 93, in __import__ 14:31:30 web.1 | result = _import(*args, **kwargs) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wtfpeewee/orm.py", line 30, in <module> 14:31:30 web.1 | from peewee import PrimaryKeyField 14:31:30 web.1 | ImportError: cannot import name PrimaryKeyField 14:31:30 web.1 | [2017-08-14 14:31:30 -0400] [9764] [INFO] Worker exiting (pid: 9764) 14:31:30 web.1 | Traceback (most recent call last): 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/bin/gunicorn", line 11, in <module> 14:31:30 web.1 | sys.exit(run()) 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run 14:31:30 web.1 | WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 203, in run 14:31:30 web.1 | super(Application, self).run() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run 14:31:30 web.1 | Arbiter(self).run() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 244, in handle_chld 14:31:30 web.1 | self.reap_workers() 14:31:30 web.1 | File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gunicorn/arbiter.py", line 524, in reap_workers 14:31:30 web.1 | raise HaltServer(reason, self.WORKER_BOOT_ERROR) 14:31:30 web.1 | gunicorn.errors.HaltServer 14:31:30 web.1 | : <HaltServer 'Worker failed to boot.' 3> 14:31:30 web.1 Exited with exit code 1
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1328/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/1328/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1327
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1327/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1327/comments
https://api.github.com/repos/coleifer/peewee/issues/1327/events
https://github.com/coleifer/peewee/issues/1327
249,796,454
MDU6SXNzdWUyNDk3OTY0NTQ=
1,327
insert many and ids
{ "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
[ "Currently if you are using Postgresql you can write:\r\n\r\n```python\r\nquery = User.insert_many([{...}, {...}, {...}]).return_id_list()\r\nids_inserted = query.execute()\r\n```\r\n\r\nIt's admittedly a weird API and not very flexible. In 3.0a it is the default to return the id list when the database supports the returning clause." ]
2017-08-12T07:57:42
2017-08-13T23:47:40
2017-08-13T23:47:39
NONE
null
Hi! Is it possible to insert many records and get them id list? Or maybe id of the last inserted. Or get the next identity value? In one transaction. In postgresql. Would be awesome!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1327/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/1327/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1326
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1326/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1326/comments
https://api.github.com/repos/coleifer/peewee/issues/1326/events
https://github.com/coleifer/peewee/issues/1326
249,771,387
MDU6SXNzdWUyNDk3NzEzODc=
1,326
Potential mistake in docs regarding operator parameter in CompoundSelect
{ "login": "aniketpanjwani", "id": 16311215, "node_id": "MDQ6VXNlcjE2MzExMjE1", "avatar_url": "https://avatars.githubusercontent.com/u/16311215?v=4", "gravatar_id": "", "url": "https://api.github.com/users/aniketpanjwani", "html_url": "https://github.com/aniketpanjwani", "followers_url": "https://api.github.com/users/aniketpanjwani/followers", "following_url": "https://api.github.com/users/aniketpanjwani/following{/other_user}", "gists_url": "https://api.github.com/users/aniketpanjwani/gists{/gist_id}", "starred_url": "https://api.github.com/users/aniketpanjwani/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/aniketpanjwani/subscriptions", "organizations_url": "https://api.github.com/users/aniketpanjwani/orgs", "repos_url": "https://api.github.com/users/aniketpanjwani/repos", "events_url": "https://api.github.com/users/aniketpanjwani/events{/privacy}", "received_events_url": "https://api.github.com/users/aniketpanjwani/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Wow, no the docs are definitely wrong. I'll update them, thanks." ]
2017-08-11T23:38:07
2017-08-13T23:47:49
2017-08-13T23:47:49
NONE
null
I'm using peewee 2.9.1 with Python 3.5.2 on Linux Mint 18 to access a PostgreSQL 9.6.2 database hosted on AWS RDS. The [documentation for CompoundSelect](http://docs.peewee-orm.com/en/latest/peewee/api.html#CompoundSelect) states that one should use a Node instance for the operator parameter in a compound query. I tried each of SQL('UNION'), SQL('INTERSECTION'), and SQL('EXCEPT'), but kept getting errors from psycopg2 and peewee with the syntax of the formatted SQL. An example of the formatted SQL is below: ``` >>> print(inds.sql() ``` `('(SELECT "t1"."id", "t1"."recid", "t1"."year", "t1"."papername", "t1"."timeofday", "t1"."newspaper_id" FROM "newspaperyears" AS t1 WHERE ("t1"."year" = %s)) <peewee.SQL object at 0x7f2d702d6518> (SELECT "t3"."id", "t3"."recid", "t3"."year", "t3"."papername", "t3"."timeofday", "t3"."newspaper_id" FROM "newspaperyears" AS t3 INNER JOIN "newspapers" AS t4 ON ("t3"."newspaper_id" = "t4"."id") WHERE ("t3"."year" = %s))', [1952, 1952])` It seems like either peewee's or psycopg2's SQL generation was directly inserting a reference to the Node instance. Noticing this, I instead simply used 'EXCEPT' instead of SQL('EXCEPT') for the operator parameter, and I was able to get the CompoundSelect query that I wanted. I checked the commit history, and it didn't seem like there has been anything addressing this type of issue between 2.9.1 and 2.10, but my apologies if I missed something.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1326/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/1326/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1325
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1325/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1325/comments
https://api.github.com/repos/coleifer/peewee/issues/1325/events
https://github.com/coleifer/peewee/issues/1325
249,037,057
MDU6SXNzdWUyNDkwMzcwNTc=
1,325
execute_sql, unexpected result
{ "login": "pepelisu", "id": 4609725, "node_id": "MDQ6VXNlcjQ2MDk3MjU=", "avatar_url": "https://avatars.githubusercontent.com/u/4609725?v=4", "gravatar_id": "", "url": "https://api.github.com/users/pepelisu", "html_url": "https://github.com/pepelisu", "followers_url": "https://api.github.com/users/pepelisu/followers", "following_url": "https://api.github.com/users/pepelisu/following{/other_user}", "gists_url": "https://api.github.com/users/pepelisu/gists{/gist_id}", "starred_url": "https://api.github.com/users/pepelisu/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/pepelisu/subscriptions", "organizations_url": "https://api.github.com/users/pepelisu/orgs", "repos_url": "https://api.github.com/users/pepelisu/repos", "events_url": "https://api.github.com/users/pepelisu/events{/privacy}", "received_events_url": "https://api.github.com/users/pepelisu/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "There must be a problem with the query as written. Peewee doesn't do anything to SQL queries passed directly to execute_sql() -- they are passed to the driver, which then executes them. I'd suggest working on the query in the database shell until you get the desired results.", "You are right, I will keep working in the query, since it seems to work with DB browser, but not in sqlite3 in terminal. \r\nThe problem was simple quotation marks, it has to be double to escape names. \r\n\r\n" ]
2017-08-09T13:49:26
2017-08-09T15:17:19
2017-08-09T14:59:25
NONE
null
Hi, While I was trying to perform a cleaning operation in a database, specifically removing the duplicates in a SQLite database. Using a piece of code similar to this: ```python db.execute_sql("DELETE FROM tableName WHERE rowid NOT IN (SELECT MIN(rowid) FROM tableName GROUP BY 'column1','column2','column3')") ``` The result is a complete delete of all entries in the database but the first one. It seems that execute_sql is not performing the grouping. If I run exactly the same query in the database with sqlite via terminal the result is the expected one. All the duplicated records are removed. I am doing something wrong or is there a bug?
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1325/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/1325/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1324
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1324/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1324/comments
https://api.github.com/repos/coleifer/peewee/issues/1324/events
https://github.com/coleifer/peewee/pull/1324
247,430,421
MDExOlB1bGxSZXF1ZXN0MTMzNzM5Njc1
1,324
fix postgresql use DictCursor save bug
{ "login": "mkxxq", "id": 6285845, "node_id": "MDQ6VXNlcjYyODU4NDU=", "avatar_url": "https://avatars.githubusercontent.com/u/6285845?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mkxxq", "html_url": "https://github.com/mkxxq", "followers_url": "https://api.github.com/users/mkxxq/followers", "following_url": "https://api.github.com/users/mkxxq/following{/other_user}", "gists_url": "https://api.github.com/users/mkxxq/gists{/gist_id}", "starred_url": "https://api.github.com/users/mkxxq/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mkxxq/subscriptions", "organizations_url": "https://api.github.com/users/mkxxq/orgs", "repos_url": "https://api.github.com/users/mkxxq/repos", "events_url": "https://api.github.com/users/mkxxq/events{/privacy}", "received_events_url": "https://api.github.com/users/mkxxq/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "wtf is this garbage? I can't tell what you changed" ]
2017-08-02T15:31:30
2018-01-31T12:38:22
2018-01-31T12:38:22
NONE
null
Hi: When peewee in postgresql and use DictCursor that one model with a not char pk use 'save' is error. test_code is : ``` from psycopg2.extras import RealDictCursor from peewee import * test_psql_db = PostgresqlDatabase('peewee_test', host='127.0.0.1', port=5432, user='postgres', password='postgres', cursor_factory=RealDictCursor) class IntPKModel(Model): pk = PrimaryKeyField() data = CharField() class Meta: database = test_psql_db class TestIntPKModelWithDictCursor(ModelTestCase): requires = [IntPKModel] def test_save(self): pi = IntPKModel(data='pi1') pi.save() ``` error like that: ``` ====================================================================== ERROR: test_save (playhouse.tests.test_models.TestIntPKModelWithDictCursor) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/xxq/prv_workspace/peewee/playhouse/tests/test_models.py", line 2368, in test_save pi.save() File "/home/xxq/prv_workspace/peewee/peewee.py", line 5385, in save pk_from_cursor = self.insert(**field_dict).execute() File "/home/xxq/prv_workspace/peewee/peewee.py", line 3746, in execute pk_row)] File "/home/xxq/prv_workspace/peewee/peewee.py", line 3744, in <listcomp> for field, column File "/home/xxq/prv_workspace/peewee/peewee.py", line 1096, in python_value return value if value is None else self.coerce(value) ValueError: invalid literal for int() with base 10: 'pk' ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1324/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/1324/timeline
null
null
false
{ "url": "https://api.github.com/repos/coleifer/peewee/pulls/1324", "html_url": "https://github.com/coleifer/peewee/pull/1324", "diff_url": "https://github.com/coleifer/peewee/pull/1324.diff", "patch_url": "https://github.com/coleifer/peewee/pull/1324.patch", "merged_at": null }
https://api.github.com/repos/coleifer/peewee/issues/1323
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1323/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1323/comments
https://api.github.com/repos/coleifer/peewee/issues/1323/events
https://github.com/coleifer/peewee/issues/1323
246,911,850
MDU6SXNzdWUyNDY5MTE4NTA=
1,323
Error when I run:- run_example in the twitter app
{ "login": "Doctor-Foxling", "id": 30374624, "node_id": "MDQ6VXNlcjMwMzc0NjI0", "avatar_url": "https://avatars.githubusercontent.com/u/30374624?v=4", "gravatar_id": "", "url": "https://api.github.com/users/Doctor-Foxling", "html_url": "https://github.com/Doctor-Foxling", "followers_url": "https://api.github.com/users/Doctor-Foxling/followers", "following_url": "https://api.github.com/users/Doctor-Foxling/following{/other_user}", "gists_url": "https://api.github.com/users/Doctor-Foxling/gists{/gist_id}", "starred_url": "https://api.github.com/users/Doctor-Foxling/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/Doctor-Foxling/subscriptions", "organizations_url": "https://api.github.com/users/Doctor-Foxling/orgs", "repos_url": "https://api.github.com/users/Doctor-Foxling/repos", "events_url": "https://api.github.com/users/Doctor-Foxling/events{/privacy}", "received_events_url": "https://api.github.com/users/Doctor-Foxling/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Without you sharing the full traceback I have no way of helping you. Are you new to python?", "Here's what I get. I should have shared the traceback yes, but I ran the code as it was without changing anything so I thought something might have gone wrong after one of the commits. Btw, is there a better way of sharing the traceback. Cheers!\r\n\r\n![1](https://user-images.githubusercontent.com/30374624/28891709-5e7eee6a-77c3-11e7-9f02-e702a412dd6e.JPG)\r\n![2](https://user-images.githubusercontent.com/30374624/28891710-5e7f201a-77c3-11e7-8719-f7766e8283f4.JPG)\r\n\r\n\r\n", "In the docs, there is a section on explicitly creating the tables: http://peewee.readthedocs.io/en/latest/peewee/example.html#creating-tables\r\n\r\nThe docs read:\r\n\r\n> In order to start using the models, its necessary to create the tables. This is a one-time operation and can be done quickly using the interactive interpreter. We can create a small helper function to accomplish this:\r\n\r\n```python\r\ndef create_tables():\r\n database.connect()\r\n database.create_tables([User, Relationship, Message])\r\n```\r\n\r\n> Open a python shell in the directory alongside the example app and execute the following:\r\n\r\n```pycon\r\n>>> from app import *\r\n>>> create_tables()\r\n```\r\n\r\nSo you'll `cd` into the twitter example and open a python interpreter and run the above 2 lines of code.", "Hi Charles,\n\nI appreciate the help but wouldn't it be better if the actual code in the\nexample had the create_tables() called in the __name__ == '__main__'\nsection, so every time someone tripped at this problem, they wouldn't\nbother you for it.\n\nOn Thu, Aug 3, 2017 at 1:00 AM, Charles Leifer <[email protected]>\nwrote:\n\n> Closed #1323 <https://github.com/coleifer/peewee/issues/1323>.\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/1323#event-1190532760>, or mute\n> the thread\n> <https://github.com/notifications/unsubscribe-auth/Ac964H883O6BXVGzlYWihwtffqAZLWzfks5sUQ2ggaJpZM4OpCwD>\n> .\n>\n" ]
2017-07-31T23:18:33
2017-08-03T21:43:07
2017-08-03T00:00:28
NONE
null
Hi, I'm new to peewee and when I run the run_example in the example twitter app I get an error somewhere in the line 131 but can't seem to find what exactly.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1323/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/1323/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1322
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1322/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1322/comments
https://api.github.com/repos/coleifer/peewee/issues/1322/events
https://github.com/coleifer/peewee/issues/1322
246,707,627
MDU6SXNzdWUyNDY3MDc2Mjc=
1,322
Unwanted 'AS' when constructing HAVING clause
{ "login": "desile", "id": 7103075, "node_id": "MDQ6VXNlcjcxMDMwNzU=", "avatar_url": "https://avatars.githubusercontent.com/u/7103075?v=4", "gravatar_id": "", "url": "https://api.github.com/users/desile", "html_url": "https://github.com/desile", "followers_url": "https://api.github.com/users/desile/followers", "following_url": "https://api.github.com/users/desile/following{/other_user}", "gists_url": "https://api.github.com/users/desile/gists{/gist_id}", "starred_url": "https://api.github.com/users/desile/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/desile/subscriptions", "organizations_url": "https://api.github.com/users/desile/orgs", "repos_url": "https://api.github.com/users/desile/repos", "events_url": "https://api.github.com/users/desile/events{/privacy}", "received_events_url": "https://api.github.com/users/desile/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Problem here https://github.com/coleifer/peewee/blob/master/peewee.py#L1741\r\nMethod `_parse_expression` calling `parse_node` , which adds 'AS'\r\n```\r\n if node._alias:\r\n sql = ' '.join((sql, 'AS', node._alias))\r\n```\r\n\r\nWhat is the best way to correct it? Maybe using named argument in `parse_node` declaration?\r\n\r\nSomething like that:\r\n```\r\n def _parse_expression(self, node, alias_map, conv):\r\n if isinstance(node.lhs, Field):\r\n conv = node.lhs\r\n lhs, lparams = self.parse_node(node.lhs, alias_map, conv, ignore_alias=True) #fix here\r\n rhs, rparams = self.parse_node(node.rhs, alias_map, conv, ignore_alias=True) #fix here\r\n if node.op == OP.IN and rhs == '()' and not rparams:\r\n return ('0 = 1' if node.flat else '(0 = 1)'), []\r\n template = '%s %s %s' if node.flat else '(%s %s %s)'\r\n sql = template % (lhs, self.get_op(node.op), rhs)\r\n return sql, lparams + rparams\r\n\r\n\r\n\r\n def parse_node(self, node, alias_map=None, conv=None, ignore_alias=False): #fix here\r\n sql, params, unknown = self._parse(node, alias_map, conv)\r\n if unknown and (conv is not None) and params:\r\n params = [conv.db_value(i) for i in params]\r\n\r\n if isinstance(node, Node):\r\n if node._negated:\r\n sql = 'NOT %s' % sql\r\n if node._alias and not ignore_alias: #fix here\r\n sql = ' '.join((sql, 'AS', node._alias))\r\n if node._ordering:\r\n sql = ' '.join((sql, node._ordering))\r\n\r\n if params and any(isinstance(p, Node) for p in params):\r\n clean_params = []\r\n clean_sql = []\r\n for idx, param in enumerate(params):\r\n if isinstance(param, Node):\r\n csql, cparams = self.parse_node(param)\r\n\r\n return sql, params\r\n```", "Same problem with ORDER BY and probably with PARTITION BY and RANGE ", "This \"problem\" has been present in peewee since at least version 2.0.0, and at present, exists in the 3.0 rewrite ([which you can see here](https://github.com/coleifer/peewee/tree/3.0a)).\r\n\r\nThe typical way to handle this is to either:\r\n\r\n1. Store the unaliased SQL entity in a variable and only call `alias()` when you need to.\r\n2. Use `SQL()` object to reference the alias directly.\r\n\r\nExample 1:\r\n\r\n```python\r\n# Sort users by number of tweets composed, when that number is less than 10\r\ncount = fn.COUNT(Tweet.id)\r\nquery = (User\r\n .select(User, count.alias('tweet_count'))\r\n .join(Tweet, JOIN.LEFT_OUTER)\r\n .group_by(User)\r\n .having(count < 10)\r\n .order_by(count))\r\n```\r\n\r\nExample 2:\r\n\r\n```python\r\n# Sort users by number of tweets composed, when that number is less than 10\r\ncount = fn.COUNT(Tweet.id).alias('tweet_count')\r\ncount_ref = SQL('tweet_count')\r\nquery = (User\r\n .select(User, count.alias('tweet_count'))\r\n .join(Tweet, JOIN.LEFT_OUTER)\r\n .group_by(User)\r\n .having(count_ref < 10)\r\n .order_by(count_ref))\r\n```", "Thx for the help! `query.order_by(field.alias(None))` worked in my case", "Oh... didn't even think about that way. I'll look at what would be involved implementing this in 3.0, the python->sql is much smarter and more flexible so should be do-able.", "This is fixed by e88dbf5145261890bc1a55a2f24ce6dfba36d8db in the 3.0a branch." ]
2017-07-31T10:09:46
2017-08-25T04:17:05
2017-08-25T04:17:05
NONE
null
Hi! When I use my peewee.Func object, which has _alias, in having(...), then Peewee adds keyword 'AS' in clause. For example: ``` field = fn.Count(SystemUser.id).alias('roles_count') query = query.having(field == 2) ``` Then I get syntax error: > ...name" HAVING ((Count("t1"."id") AS roles_count... I construct queries automatically from rest-requests, so I need to take fields from query.get_query_meta()[0] for comparing with requests and constructing query. It is easy just clean _alias before constructing query and problem will go away, but nevertheless I think that it is strange behavior. Thanks for attention!
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1322/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/1322/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1321
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1321/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1321/comments
https://api.github.com/repos/coleifer/peewee/issues/1321/events
https://github.com/coleifer/peewee/issues/1321
246,454,856
MDU6SXNzdWUyNDY0NTQ4NTY=
1,321
UpdateQuery FROM clause support
{ "login": "rammie", "id": 554792, "node_id": "MDQ6VXNlcjU1NDc5Mg==", "avatar_url": "https://avatars.githubusercontent.com/u/554792?v=4", "gravatar_id": "", "url": "https://api.github.com/users/rammie", "html_url": "https://github.com/rammie", "followers_url": "https://api.github.com/users/rammie/followers", "following_url": "https://api.github.com/users/rammie/following{/other_user}", "gists_url": "https://api.github.com/users/rammie/gists{/gist_id}", "starred_url": "https://api.github.com/users/rammie/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/rammie/subscriptions", "organizations_url": "https://api.github.com/users/rammie/orgs", "repos_url": "https://api.github.com/users/rammie/repos", "events_url": "https://api.github.com/users/rammie/events{/privacy}", "received_events_url": "https://api.github.com/users/rammie/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Doesn't seem worth the trouble. The subquery would likely be cached if it appears twice. Sorry for the noise.", "Well, I think it should be added to Peewee. Currently I don't see any ways in Peewee to do what `UPDATE FROM` does — to update one table using a joined table not only in `WHERE` (which could really be done with subqueries), but also as data source for expression in `SET`.\r\n\r\n@coleifer, is there any chance that you will add this?", "It gets a bit weird...SQLite does not support fully-qualified column names in the SET portion of the query. I *believe* it's possible to accomplish anything you need without the `FROM` clause that would normally be possible using sub-selects or common-table-expressions. Closing." ]
2017-07-28T20:44:47
2017-10-02T20:33:17
2017-10-02T20:33:17
NONE
null
Turns out postgresql's Update statements support a FROM clause that is useful for doing bulk updates. I don't think this is standard SQL. I looked through the documentation and couldn't find any examples of it. I perused the generate_update function in peewee and didn't see and SQL('FROM')'s in there so I assume that this is not supported. I found this on the group, which is a related question. https://groups.google.com/forum/#!topic/peewee-orm/ov4M434fZ7U It would be nice if peewee supported this. I was wondering if you had any suggestions on how to achieve this. Standard disclaimer: I love peewee! It's my favorite ORM ever.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1321/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/1321/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1320
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1320/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1320/comments
https://api.github.com/repos/coleifer/peewee/issues/1320/events
https://github.com/coleifer/peewee/issues/1320
244,091,418
MDU6SXNzdWUyNDQwOTE0MTg=
1,320
ForeignKeyField('self',…) not correctly inheriting?
{ "login": "phryk", "id": 1021513, "node_id": "MDQ6VXNlcjEwMjE1MTM=", "avatar_url": "https://avatars.githubusercontent.com/u/1021513?v=4", "gravatar_id": "", "url": "https://api.github.com/users/phryk", "html_url": "https://github.com/phryk", "followers_url": "https://api.github.com/users/phryk/followers", "following_url": "https://api.github.com/users/phryk/following{/other_user}", "gists_url": "https://api.github.com/users/phryk/gists{/gist_id}", "starred_url": "https://api.github.com/users/phryk/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/phryk/subscriptions", "organizations_url": "https://api.github.com/users/phryk/orgs", "repos_url": "https://api.github.com/users/phryk/repos", "events_url": "https://api.github.com/users/phryk/events{/privacy}", "received_events_url": "https://api.github.com/users/phryk/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Interesting... Out of curiosity I tested this on Django, and found it behaves the same as Peewee in this case.\r\n\r\nYou should be able to re-define the foreign key on the child table and I'm going to suggest that should be the proper resolution to this issue. Doing some kind of late-late-binding of the foreign key model doesn't really work because it's not clear at what point that binding should be done." ]
2017-07-19T15:58:57
2017-07-20T13:59:45
2017-07-20T13:59:45
NONE
null
When inheriting from a Model using `ForeignKeyField('self',…)`, the resulting table references the (possibly inexistent) table of the Model originally defining the key. I'm not sure whether this is intended behavior but intuitively, I expected the inherited models to also reference themselves, rather than some class further up. I wrote a bit of code to illustrate what I'm trying to do and where it fails. Since I haven't seen any good way to attach files to issues, I'm just pasting it verbatim: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- import peewee db = peewee.SqliteDatabase('test.db') class Forestable(peewee.Model): class Meta: database = db name = peewee.CharField(unique=True) parent = peewee.ForeignKeyField('self', null=True) class SubForestable(Forestable): pass if __name__ == '__main__': SubForestable.create_table() x = SubForestable() x.name = 'foo' x.save() y = SubForestable() y.name = 'bar' y.parent = x y.save() # works fine print "X:" print x print x.name print x.parent print "--" print "Y:" print y print y.name print y.parent print "--" # works fine up to… q = SubForestable.select() for z in q: print z print z.name print z.parent # here, where it tries accessing table 'forestable' ``` I tested this with 2.10.1 from pip and the 3.0a branch from git.
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1320/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/1320/timeline
null
completed
null
null
https://api.github.com/repos/coleifer/peewee/issues/1319
https://api.github.com/repos/coleifer/peewee
https://api.github.com/repos/coleifer/peewee/issues/1319/labels{/name}
https://api.github.com/repos/coleifer/peewee/issues/1319/comments
https://api.github.com/repos/coleifer/peewee/issues/1319/events
https://github.com/coleifer/peewee/issues/1319
243,017,478
MDU6SXNzdWUyNDMwMTc0Nzg=
1,319
InternalError: (1054, u"Unknown column 't1.pk' in 'field list'")
{ "login": "guangbaowan", "id": 25094780, "node_id": "MDQ6VXNlcjI1MDk0Nzgw", "avatar_url": "https://avatars.githubusercontent.com/u/25094780?v=4", "gravatar_id": "", "url": "https://api.github.com/users/guangbaowan", "html_url": "https://github.com/guangbaowan", "followers_url": "https://api.github.com/users/guangbaowan/followers", "following_url": "https://api.github.com/users/guangbaowan/following{/other_user}", "gists_url": "https://api.github.com/users/guangbaowan/gists{/gist_id}", "starred_url": "https://api.github.com/users/guangbaowan/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/guangbaowan/subscriptions", "organizations_url": "https://api.github.com/users/guangbaowan/orgs", "repos_url": "https://api.github.com/users/guangbaowan/repos", "events_url": "https://api.github.com/users/guangbaowan/events{/privacy}", "received_events_url": "https://api.github.com/users/guangbaowan/received_events", "type": "User", "site_admin": false }
[]
closed
false
null
[]
null
[ "Can you share your definition of MySqlPrimaryKeyAutoIncrementField ? Also, it should be MyModel.select().first() (your ex has missing parentheses after select).", "@coleifer \r\n.Oh . sorry .(MyModel.select.first(), here is the typo, in my code, I typed the right one )\r\n```\r\nclass MySqlPrimaryKeyAutoIncrementField(BigIntegerField):\r\n def __init__(self, *args, **kwargs):\r\n kwargs['primary_key'] = True\r\n super(MySqlPrimaryKeyAutoIncrementField, self).__init__(*args, **kwargs)\r\n\r\n def __ddl__(self, column_type):\r\n ddl = super(MySqlPrimaryKeyAutoIncrementField, self).__ddl__(column_type)\r\n return ddl + [SQL('auto_increment')]\r\n```", "I'm really confused. when I use\r\n```\r\nmysql_db = MySQLDatabase('test', host='127.0.0.1', port=3306, user='root', passowrd='root')\r\n```\r\nworked well.", "In your `__ddl__` method you're not returning anything. That's the issue." ]
2017-07-14T14:41:11
2017-07-14T16:38:19
2017-07-14T16:32:56
NONE
null
Hi, here is my code. I used the connection pool and created the table, when use MyModel.select.first(), but returns 'InternalError: (1054, u"Unknown column 't1.pk' in 'field list'")', am I doing something wrong? ``` from playhouse.db_url import connect mysql_db = connect('mysql+pool://root:[email protected]:3306/test?max_connections=20&stale_timeout=300') from promotion_service.store import MySqlPrimaryKeyAutoIncrementField class MyModel(Model): pk = MySqlPrimaryKeyAutoIncrementField() other_field = TextField() class Meta: db_table = 'my_model' database = mysql_db ```
{ "url": "https://api.github.com/repos/coleifer/peewee/issues/1319/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/1319/timeline
null
completed
null
null