workspace
stringclasses
1 value
channel
stringclasses
1 value
sentences
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
sentence_id
stringlengths
44
53
timestamp
float64
1.5B
1.56B
__index_level_0__
int64
0
106k
pythondev
help
it’s the defacto library for working with relational databases in python
2017-10-24T11:06:23.000621
Johana
pythondev_help_Johana_2017-10-24T11:06:23.000621
1,508,843,183.000621
98,103
pythondev
help
hey <@Johana> Thanks for the suggestion what your thoughts on django ?
2017-10-24T11:08:03.000048
Burma
pythondev_help_Burma_2017-10-24T11:08:03.000048
1,508,843,283.000048
98,104
pythondev
help
I like django. i believe you can use the orm if you like separately from the web application.
2017-10-24T11:08:33.000209
Johana
pythondev_help_Johana_2017-10-24T11:08:33.000209
1,508,843,313.000209
98,105
pythondev
help
the function is to make queries to a monitoring DB
2017-10-24T11:09:38.000641
Burma
pythondev_help_Burma_2017-10-24T11:09:38.000641
1,508,843,378.000641
98,106
pythondev
help
How familiar are you with SQL?
2017-10-24T11:11:25.000117
Johana
pythondev_help_Johana_2017-10-24T11:11:25.000117
1,508,843,485.000117
98,107
pythondev
help
from 1 to 10 I would say 3
2017-10-24T11:12:02.000731
Burma
pythondev_help_Burma_2017-10-24T11:12:02.000731
1,508,843,522.000731
98,108
pythondev
help
maybe 4
2017-10-24T11:12:08.000525
Burma
pythondev_help_Burma_2017-10-24T11:12:08.000525
1,508,843,528.000525
98,109
pythondev
help
Hello, I’m having trouble getting a python Cycle Finder to work. Can anyone help me convert this cycle finder to work with the edge list data structure? ``` a = { 'A': [('B', 3), ('D', 4)], 'B': [('A', 3), ('E', 4), ('F', 6)], 'C': [('E', 5)], 'D': [('A', 4)], 'E': [('B', 4), ('F', 5), ('C', 5)], 'F': [('B', 6), ('E', 5)] } def cycle_exists(G): marked = {u: False for u in G} found_cycle = [False] for u in G: if not marked[u]: dfs_visit(G, u, found_cycle, u, marked) if found_cycle[0]: break return found_cycle[0] # -------- def dfs_visit(G, u, found_cycle, pred_node, marked): if found_cycle[0]: return marked[u] = True for v in G[u]: if marked[v] and v != pred_node: found_cycle[0] = True return if not marked[v]: dfs_visit(G, v, found_cycle, u, marked) print cycle_exists(a) ```
2017-10-24T11:12:25.000424
Honey
pythondev_help_Honey_2017-10-24T11:12:25.000424
1,508,843,545.000424
98,110
pythondev
help
ok so if you were to write raw sql queries you would have to learn SQL.
2017-10-24T11:13:01.000356
Johana
pythondev_help_Johana_2017-10-24T11:13:01.000356
1,508,843,581.000356
98,111
pythondev
help
so that would probably take the most time/effort.
2017-10-24T11:13:11.000516
Johana
pythondev_help_Johana_2017-10-24T11:13:11.000516
1,508,843,591.000516
98,112
pythondev
help
if you were to try and use the sqlalchemy orm you could work with the database in a more object oriented manner.
2017-10-24T11:13:28.000487
Johana
pythondev_help_Johana_2017-10-24T11:13:28.000487
1,508,843,608.000487
98,113
pythondev
help
which is a bit easier for beginners.
2017-10-24T11:13:36.000226
Johana
pythondev_help_Johana_2017-10-24T11:13:36.000226
1,508,843,616.000226
98,114
pythondev
help
:point_up: this snippet will show you how you can reflect the database and start querying it.
2017-10-24T11:13:59.000556
Johana
pythondev_help_Johana_2017-10-24T11:13:59.000556
1,508,843,639.000556
98,115
pythondev
help
ok sounds good not that I don't mind putting the time in and learning to write sql queries
2017-10-24T11:14:33.000018
Burma
pythondev_help_Burma_2017-10-24T11:14:33.000018
1,508,843,673.000018
98,116
pythondev
help
yea, i’m not saying you do. i’m thinking in perspective of time usage.
2017-10-24T11:14:53.000401
Johana
pythondev_help_Johana_2017-10-24T11:14:53.000401
1,508,843,693.000401
98,117
pythondev
help
you would need to alter the connection string and it will work for mysql.
2017-10-24T11:15:26.000203
Johana
pythondev_help_Johana_2017-10-24T11:15:26.000203
1,508,843,726.000203
98,118
pythondev
help
that’s the beauty of using something like sqlalchemy. it has abstracted the nuances of the different databases.
2017-10-24T11:15:39.000210
Johana
pythondev_help_Johana_2017-10-24T11:15:39.000210
1,508,843,739.00021
98,119
pythondev
help
if you want to switch to postgres you can pretty much just change the connection string.
2017-10-24T11:15:50.000311
Johana
pythondev_help_Johana_2017-10-24T11:15:50.000311
1,508,843,750.000311
98,120
pythondev
help
yea I know exactly what you mean by the time efficiency
2017-10-24T11:16:51.000527
Burma
pythondev_help_Burma_2017-10-24T11:16:51.000527
1,508,843,811.000527
98,121
pythondev
help
and all your queries will work. you can’t say that with raw sql.
2017-10-24T11:16:55.000344
Johana
pythondev_help_Johana_2017-10-24T11:16:55.000344
1,508,843,815.000344
98,122
pythondev
help
that’s the power of sqlalchemy. you never have to worry about if you can talk to a database. it pretty much covers all the major relational databases out there.
2017-10-24T11:17:27.000024
Johana
pythondev_help_Johana_2017-10-24T11:17:27.000024
1,508,843,847.000024
98,123
pythondev
help
I can add some explanation to the snippet.
2017-10-24T11:17:45.000356
Johana
pythondev_help_Johana_2017-10-24T11:17:45.000356
1,508,843,865.000356
98,124
pythondev
help
essentially what is happening is in sqlalchemy you need an `engine`.
2017-10-24T11:17:58.000295
Johana
pythondev_help_Johana_2017-10-24T11:17:58.000295
1,508,843,878.000295
98,125
pythondev
help
this engine is the connection to the DBAPI.
2017-10-24T11:18:07.000066
Johana
pythondev_help_Johana_2017-10-24T11:18:07.000066
1,508,843,887.000066
98,126
pythondev
help
it generates sql queries for you.
2017-10-24T11:18:14.000098
Johana
pythondev_help_Johana_2017-10-24T11:18:14.000098
1,508,843,894.000098
98,127
pythondev
help
The ORM is built on top of that.
2017-10-24T11:18:21.000084
Johana
pythondev_help_Johana_2017-10-24T11:18:21.000084
1,508,843,901.000084
98,128
pythondev
help
You need the `session` which is bound to the `engine` in order to use the ORM.
2017-10-24T11:18:40.000352
Johana
pythondev_help_Johana_2017-10-24T11:18:40.000352
1,508,843,920.000352
98,129
pythondev
help
you could use the engine alone. or you can use the session. if you decide to use the session you have to use SQLAlchemy’s Expression language which looks like SQL, `select([Users.c.name]).where(Users.c.name == 'mike')`
2017-10-24T11:19:36.000167
Johana
pythondev_help_Johana_2017-10-24T11:19:36.000167
1,508,843,976.000167
98,130
pythondev
help
that’s the equivalent of ``` SELECT * FROM USERS WHERE name = 'mike' ```
2017-10-24T11:20:04.000028
Johana
pythondev_help_Johana_2017-10-24T11:20:04.000028
1,508,844,004.000028
98,131
pythondev
help
The ORM provides a more declarative way to talk to the database.
2017-10-24T11:20:21.000548
Johana
pythondev_help_Johana_2017-10-24T11:20:21.000548
1,508,844,021.000548
98,132
pythondev
help
You essentially create a class that represents the table in your database.
2017-10-24T11:20:49.000278
Johana
pythondev_help_Johana_2017-10-24T11:20:49.000278
1,508,844,049.000278
98,133
pythondev
help
and just to get this right the session interacts with the ORM ?
2017-10-24T11:20:57.000102
Burma
pythondev_help_Burma_2017-10-24T11:20:57.000102
1,508,844,057.000102
98,134
pythondev
help
I’m doing that above by reflecting the db.
2017-10-24T11:20:58.000749
Johana
pythondev_help_Johana_2017-10-24T11:20:58.000749
1,508,844,058.000749
98,135
pythondev
help
yes!
2017-10-24T11:21:03.000084
Johana
pythondev_help_Johana_2017-10-24T11:21:03.000084
1,508,844,063.000084
98,136
pythondev
help
the session is like a recorder. You can add things to it (insert) you can take things away(delete) etc.
2017-10-24T11:21:21.000466
Johana
pythondev_help_Johana_2017-10-24T11:21:21.000466
1,508,844,081.000466
98,137
pythondev
help
If you want to add a user you can do something like this: ``` user = User(name='mike) session.add(user) session.commit() ```
2017-10-24T11:21:56.000677
Johana
pythondev_help_Johana_2017-10-24T11:21:56.000677
1,508,844,116.000677
98,138
pythondev
help
So i guess session maybe the way to go then again I wouldnt mind learning the engine as well but it might be more of a learning curve
2017-10-24T11:22:11.000018
Burma
pythondev_help_Burma_2017-10-24T11:22:11.000018
1,508,844,131.000018
98,139
pythondev
help
so now you can work with the database as you would any other python object.
2017-10-24T11:22:21.000219
Johana
pythondev_help_Johana_2017-10-24T11:22:21.000219
1,508,844,141.000219
98,140
pythondev
help
i would learn the core after the ORM.
2017-10-24T11:22:28.000316
Johana
pythondev_help_Johana_2017-10-24T11:22:28.000316
1,508,844,148.000316
98,141
pythondev
help
SQLAlchemy is stand-alone so you can integrate it into anything.
2017-10-24T11:22:48.000149
Johana
pythondev_help_Johana_2017-10-24T11:22:48.000149
1,508,844,168.000149
98,142
pythondev
help
a CLI app you got it, a web app you goit.
2017-10-24T11:22:55.000133
Johana
pythondev_help_Johana_2017-10-24T11:22:55.000133
1,508,844,175.000133
98,143
pythondev
help
here is a flask app that uses sqlalchemy. <https://gist.github.com/m1yag1/d354ab69398ab84f72f9e0b8c712ffb6>
2017-10-24T11:23:29.000796
Johana
pythondev_help_Johana_2017-10-24T11:23:29.000796
1,508,844,209.000796
98,144
pythondev
help
nice thats pretty damn cool !
2017-10-24T11:23:41.000011
Burma
pythondev_help_Burma_2017-10-24T11:23:41.000011
1,508,844,221.000011
98,145
pythondev
help
check out lines 171-87
2017-10-24T11:23:57.000469
Johana
pythondev_help_Johana_2017-10-24T11:23:57.000469
1,508,844,237.000469
98,146
pythondev
help
that’s a class model of the table in the database.
2017-10-24T11:24:09.000030
Johana
pythondev_help_Johana_2017-10-24T11:24:09.000030
1,508,844,249.00003
98,147
pythondev
help
it’s faster if you model your database this way. you may have to do that. or you can reflect the db like in my first example.
2017-10-24T11:24:30.000103
Johana
pythondev_help_Johana_2017-10-24T11:24:30.000103
1,508,844,270.000103
98,148
pythondev
help
sqlacodegen is a library that can generate a models.py file for you by reflecting the database.
2017-10-24T11:25:04.000157
Johana
pythondev_help_Johana_2017-10-24T11:25:04.000157
1,508,844,304.000157
98,149
pythondev
help
i’ve successfully ported applications using this very feature from microsoft sql server to postgresql.
2017-10-24T11:27:15.000333
Johana
pythondev_help_Johana_2017-10-24T11:27:15.000333
1,508,844,435.000333
98,150
pythondev
help
if you don't mind me asking ```sqlacodegen is a library that can generate a models.py file for you by reflecting the database ?```
2017-10-24T11:28:54.000413
Burma
pythondev_help_Burma_2017-10-24T11:28:54.000413
1,508,844,534.000413
98,151
pythondev
help
typically an ORM or database library needs to “know” how the database schema looks like.
2017-10-24T11:29:35.000317
Johana
pythondev_help_Johana_2017-10-24T11:29:35.000317
1,508,844,575.000317
98,152
pythondev
help
why would I have to reflect my database ? in this this instance
2017-10-24T11:29:35.000595
Burma
pythondev_help_Burma_2017-10-24T11:29:35.000595
1,508,844,575.000595
98,153
pythondev
help
it does this via reflection.
2017-10-24T11:29:39.000267
Johana
pythondev_help_Johana_2017-10-24T11:29:39.000267
1,508,844,579.000267
98,154
pythondev
help
ohh !
2017-10-24T11:29:44.000433
Burma
pythondev_help_Burma_2017-10-24T11:29:44.000433
1,508,844,584.000433
98,155
pythondev
help
it’s just an easy way to start working with the database.
2017-10-24T11:29:51.000479
Johana
pythondev_help_Johana_2017-10-24T11:29:51.000479
1,508,844,591.000479
98,156
pythondev
help
:+1:
2017-10-24T11:29:53.000350
Burma
pythondev_help_Burma_2017-10-24T11:29:53.000350
1,508,844,593.00035
98,157
pythondev
help
i use it a lot to do adhoc queries.
2017-10-24T11:29:58.000685
Johana
pythondev_help_Johana_2017-10-24T11:29:58.000685
1,508,844,598.000685
98,158
pythondev
help
i do not recommend it for applications with a lot of db tables.
2017-10-24T11:30:09.000084
Johana
pythondev_help_Johana_2017-10-24T11:30:09.000084
1,508,844,609.000084
98,159
pythondev
help
it can slow things down trying to “reverse engineer” the database schema if the database has tons of tables.
2017-10-24T11:30:21.000016
Johana
pythondev_help_Johana_2017-10-24T11:30:21.000016
1,508,844,621.000016
98,160
pythondev
help
hmm makes sense
2017-10-24T11:30:52.000496
Burma
pythondev_help_Burma_2017-10-24T11:30:52.000496
1,508,844,652.000496
98,161
pythondev
help
i wrote an app a couple years back that would reflect a database and provide a web api for CRUD on all the tables. it took like 10minutes to reflect the db.
2017-10-24T11:31:09.000416
Johana
pythondev_help_Johana_2017-10-24T11:31:09.000416
1,508,844,669.000416
98,162
pythondev
help
lol
2017-10-24T11:31:10.000743
Johana
pythondev_help_Johana_2017-10-24T11:31:10.000743
1,508,844,670.000743
98,163
pythondev
help
CRUD = create update and delete
2017-10-24T11:31:19.000479
Johana
pythondev_help_Johana_2017-10-24T11:31:19.000479
1,508,844,679.000479
98,164
pythondev
help
lol must of been extremely heavy yea basically I'll be making direct queries with an nagios like monitoring tool
2017-10-24T11:32:30.000915
Burma
pythondev_help_Burma_2017-10-24T11:32:30.000915
1,508,844,750.000915
98,165
pythondev
help
but I''l be pulling values directly from the DB
2017-10-24T11:32:56.000817
Burma
pythondev_help_Burma_2017-10-24T11:32:56.000817
1,508,844,776.000817
98,166
pythondev
help
but this should help me more than enough to get started
2017-10-24T11:33:14.000889
Burma
pythondev_help_Burma_2017-10-24T11:33:14.000889
1,508,844,794.000889
98,167
pythondev
help
that’s fine.
2017-10-24T11:33:18.000300
Johana
pythondev_help_Johana_2017-10-24T11:33:18.000300
1,508,844,798.0003
98,168
pythondev
help
you can even create another engine for another db and and save to a different database lol.
2017-10-24T11:33:32.000432
Johana
pythondev_help_Johana_2017-10-24T11:33:32.000432
1,508,844,812.000432
98,169
pythondev
help
if you needed to save locally for example.
2017-10-24T11:33:38.000264
Johana
pythondev_help_Johana_2017-10-24T11:33:38.000264
1,508,844,818.000264
98,170
pythondev
help
Interesting Yea I'll certainly take that idea Thanks again man <@Johana> :+1:
2017-10-24T11:35:16.000495
Burma
pythondev_help_Burma_2017-10-24T11:35:16.000495
1,508,844,916.000495
98,171
pythondev
help
np, i came into python via sqlalchemy i was a DBA in a past life :wink:.
2017-10-24T11:35:32.000230
Johana
pythondev_help_Johana_2017-10-24T11:35:32.000230
1,508,844,932.00023
98,172
pythondev
help
i got into web dev b/c i wanted to show data quickly to business users so then flask was a nice fit.
2017-10-24T11:36:13.000777
Johana
pythondev_help_Johana_2017-10-24T11:36:13.000777
1,508,844,973.000777
98,173
pythondev
help
as a past database administrator i can tell you for a fact sqlalchemy is bad ass.
2017-10-24T11:36:43.000236
Johana
pythondev_help_Johana_2017-10-24T11:36:43.000236
1,508,845,003.000236
98,174
pythondev
help
it is 10years old after all.
2017-10-24T11:37:03.000410
Johana
pythondev_help_Johana_2017-10-24T11:37:03.000410
1,508,845,023.00041
98,175
pythondev
help
let me know how it goes <@Burma>
2017-10-24T11:38:04.000445
Johana
pythondev_help_Johana_2017-10-24T11:38:04.000445
1,508,845,084.000445
98,176
pythondev
help
<@Johana> I am trying to create a workflow for my buddy and I to work on a couple different webapps. Basically it consists of our local computers, the server where svn is hosting all my projects and then the production server to host the live webserver. I was talking with a coworker about it and he had mentioned setuptools might be useful for installing the projects out on the live server rather than having a make file just call *svn up* out on the production server. Setuptools is something I've avoided for a long while so I may not be explaining myself very well
2017-10-24T11:39:25.000677
Lory
pythondev_help_Lory_2017-10-24T11:39:25.000677
1,508,845,165.000677
98,177
pythondev
help
setuptools isn’t going to go put it on your server. you can use distutils to create a source distribution which is fine.
2017-10-24T11:40:33.000383
Johana
pythondev_help_Johana_2017-10-24T11:40:33.000383
1,508,845,233.000383
98,178
pythondev
help
it will essentially create a tarball of your app you can copy to the server and extract.
2017-10-24T11:40:49.000270
Johana
pythondev_help_Johana_2017-10-24T11:40:49.000270
1,508,845,249.00027
98,179
pythondev
help
you’ll use distutils for that.
2017-10-24T11:41:07.000142
Johana
pythondev_help_Johana_2017-10-24T11:41:07.000142
1,508,845,267.000142
98,180
pythondev
help
Personally, i would use something like ansible or docker to deploy your app.
2017-10-24T11:41:43.000496
Johana
pythondev_help_Johana_2017-10-24T11:41:43.000496
1,508,845,303.000496
98,181
pythondev
help
two things for that you will need a `<http://Manifest.in|Manifest.in>` file and `setup.py`
2017-10-24T11:42:44.000288
Johana
pythondev_help_Johana_2017-10-24T11:42:44.000288
1,508,845,364.000288
98,182
pythondev
help
the idea is to create what is known as a “build artifact”.
2017-10-24T11:43:50.000208
Johana
pythondev_help_Johana_2017-10-24T11:43:50.000208
1,508,845,430.000208
98,183
pythondev
help
Will do <@Johana>
2017-10-24T11:44:29.000007
Burma
pythondev_help_Burma_2017-10-24T11:44:29.000007
1,508,845,469.000007
98,184
pythondev
help
a build artifact is like a windows .exe or a .deb file or a python wheel.
2017-10-24T11:45:36.000566
Johana
pythondev_help_Johana_2017-10-24T11:45:36.000566
1,508,845,536.000566
98,185
pythondev
help
if you go the ansible route you can create a playbook with your buddy and only have your keys on the server so that only you two can deploy.
2017-10-24T11:48:35.000500
Johana
pythondev_help_Johana_2017-10-24T11:48:35.000500
1,508,845,715.0005
98,186
pythondev
help
you can checkout pyslackers github for examples: <https://github.com/pyslackers/website/blob/master/ansible/playbook.yml>
2017-10-24T11:49:24.000468
Johana
pythondev_help_Johana_2017-10-24T11:49:24.000468
1,508,845,764.000468
98,187
pythondev
help
interesting, looks like I was a bit confused about what's what. I'll look deeper into distutils and how it all works. Once I understand that aspect I'll look back at how to deploy it from there
2017-10-24T12:01:37.000148
Lory
pythondev_help_Lory_2017-10-24T12:01:37.000148
1,508,846,497.000148
98,188
pythondev
help
i’m a bit busy but i’ll be back with an example :wink:
2017-10-24T12:03:35.000853
Johana
pythondev_help_Johana_2017-10-24T12:03:35.000853
1,508,846,615.000853
98,189
pythondev
help
this is the ansible task that I have that creates a source distro before it copies it to my server: ``` - name: Create source distribution sudo: false local_action: shell source {{ pylocal_venv }}/bin/activate &amp;&amp; python setup.py clean sdist chdir="{{ pylocal_source_dir }}" executable="/bin/bash" run_once: true ```
2017-10-24T12:08:28.000320
Johana
pythondev_help_Johana_2017-10-24T12:08:28.000320
1,508,846,908.00032
98,190
pythondev
help
replace the jinja tags with the proper values
2017-10-24T12:08:53.000376
Johana
pythondev_help_Johana_2017-10-24T12:08:53.000376
1,508,846,933.000376
98,191
pythondev
help
`source virtualenv_path/bin/activate &amp;&amp; python setup.py clean sdist chdir=/application/dir`
2017-10-24T12:09:47.000043
Johana
pythondev_help_Johana_2017-10-24T12:09:47.000043
1,508,846,987.000043
98,192
pythondev
help
you can then scp or sftp the source distro to the server.
2017-10-24T12:12:26.000464
Johana
pythondev_help_Johana_2017-10-24T12:12:26.000464
1,508,847,146.000464
98,193
pythondev
help
if you want to do it manually.
2017-10-24T12:12:31.000053
Johana
pythondev_help_Johana_2017-10-24T12:12:31.000053
1,508,847,151.000053
98,194
pythondev
help
in ansible extracting an archive is pretty easy: ``` - name: Copy and extract source onto server unarchive: src: /local/dir/ dest: /remote/dir ```
2017-10-24T12:15:53.000399
Johana
pythondev_help_Johana_2017-10-24T12:15:53.000399
1,508,847,353.000399
98,195
pythondev
help
Let’s say I have a solution triple: {(t, 2t, 3t)}. How can I find a fitting 3x3 linear system of equations? t is just a parameter
2017-10-24T12:16:34.000719
Hannah
pythondev_help_Hannah_2017-10-24T12:16:34.000719
1,508,847,394.000719
98,196
pythondev
help
<@Vita> apparently you can have MANY you tube videos playing at 2x speed, beware it may make you bonkers though, LOL. I found presentations but I couldn't find the panel discussion. Here's Guido in 2015 ( <https://www.youtube.com/watch?v=2wDvzy6Hgxg> )and th emore I look the more I think the panel *may* have been 2016.
2017-10-24T15:28:25.000301
Seema
pythondev_help_Seema_2017-10-24T15:28:25.000301
1,508,858,905.000301
98,197
pythondev
help
Lol cool, thanks for sending me this!
2017-10-24T15:29:28.000112
Vita
pythondev_help_Vita_2017-10-24T15:29:28.000112
1,508,858,968.000112
98,198
pythondev
help
hi guys, i was going through django channels in <https://realpython.com/blog/python/getting-started-with-django-channels/> . i followed the instructions, but i'm getting this error. ERROR - server - Error trying to receive messages: name 'txredisapi' is not defined. Thank you
2017-10-24T16:39:17.000207
Horace
pythondev_help_Horace_2017-10-24T16:39:17.000207
1,508,863,157.000207
98,199
pythondev
help
can anyone help me with this
2017-10-24T16:39:40.000016
Horace
pythondev_help_Horace_2017-10-24T16:39:40.000016
1,508,863,180.000016
98,200
pythondev
help
how to print the present month in words. example 'October '
2017-10-25T01:12:11.000112
Emily
pythondev_help_Emily_2017-10-25T01:12:11.000112
1,508,893,931.000112
98,201
pythondev
help
@mock you might wanna go in a bit more detail. In what context is this? Just a simple single line?
2017-10-25T01:23:23.000079
Myong
pythondev_help_Myong_2017-10-25T01:23:23.000079
1,508,894,603.000079
98,202