#databases
1 messages · Page 43 of 1
It only does it once, and only after you push the task onto it
It's so much easier to explain asyncio with a visual reperentaion
screen share?
Yeah, something like that
Don't think too hard
Most people come into this stuff assuming it's difficult and they won't understand it
but really it's not that complicated
what is wrong with user = sqlite3.connect('users.db') user.execute("UPDATE USER set subscribed = ? where ID = ?", (str(0), str(id))) user.commit()?
Dunno, what's wrong with it?
yeah, what he said
<@&267630620367257601> I need some help writing to specific parts of a notepad file
i have a user list in notepad
And you want to edit one line?
each user separated by lines, and each piece of info (username, password, score) is separated by commas
no i want to edit one of the thnigs separated by the commas
Like a csv file?
You'll have to split up the lines into an array and then each user into an array
yeah but i used txt
Isn't that a bit unsafe?
Why not use an acual database
@sacred heart It doesn't really matter, that's like calling JSON unsafe
Reasons @high gust
what if the username contains a comma
@potent lintel can use whatever he wants, you guys are going to assist for his needs not tell him to use something else
i was initially going to use JSON but i can't
@torn sphinx irrelevant
@torn sphinx i've validated that
@potent lintel So what you'll need to do is get all the lines into an array
and then use line.split(",")
i've already done those two
then you'll have an array of the values of one line
Yeah edit whatever you want and then use file.writelines(array)
how do i specify which line
oh
Do you mean which line to edit?
No i can already get that
Ahh okay
well yeah just split into an array, edit a value and then put back into a larger array of lines
then file.writelines(array)
https://stackoverflow.com/a/4719562 like this a little bit
No problem
@deft badge I swear f.writelines doesn't actually exist
Type exit or quit to end
t = open("f.txt")
Traceback (most recent call last):
File "/home/joseph/pybutt-rewrite/cogs/repl.py", line 103, in repl
result = executor(code, variables) # var code may be referenced before assignment
File "<repl session>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'f.txt'
oh
gg.
<built-in method writelines of _io.TextIOWrapper object at 0x7f7fe9a37ea0>
t.close()
lmao
e.e
:D
Does anyone know of an example of Python, MongoDb and Cisco switches?
@dusty wolf never used a Cisco Switch, but Python and Mongo is simple enough. Though, know your needs because Mongo isn’t and never will be ACID-compliant
oze - Today at 11:39 AM
oioi
I have a rather general question:
I have existing data and want to import it into a fresh SQL-Alchemy/Flask database
those data-sets already have a unique ID, i.e. primary-key
how do I ensure that the existing ids/primarykeys are used in my table as actualy primary-keys for my db
is setting auto-increment to "off"
for my fresh primary-key/integer column, i.e. table in my SQL db-model...
enough?
*actual
oh yeah: possibly relevant .. the existing ids/primarykeys do not start at 1
I cannot import PyMongo because it couldn't be possible to find flask.ext.pymongo first, can anyone tell me why?
Proably because you don't have flask.ext.pymongo
Isn't downloading the package flask enough?
👍
And how can I let the system read a single line of a database document?
Like:
[1] a
[2] b
[3] c
and I want the system to read only the line 2
@onyx gate This issue is very old, but did you ever fix it?
Hey! Yes, I fixed this but there are some things that I would like to get help with
@ornate abyss
Hi everyone! Before I start reinventing the wheel, I want to check if there's an existing Python library to do XMLSQL web queries. I Googled and it doesn't seem to be a standard? Basically, sending SQL queries over XML via forms.
So a sample query would be like this:
<QUERY metadata='true'>
<SQL>SELECT personid, name, lasttransdate, binaryobjectid, payfeeatpof from person
where name='Smith'</SQL>
</QUERY>
a client request, they have this rather odd server, that i'm wondering if they wrote from scratch, or they based off some library they found in Java or something
It's not something I've ever heard of, nor is it something I can find any mentions of
if I can't find a library, i'll just have to roll out my own Python implementation to send their XMLSQL requests
I'd say you might be on your own with that one
Is that actually sending SQL directly to the database?
Because you really don't want to be running SQL from a user..
oh this is an internal facing app
the computers might even just be connected to each other directly via ethernet, heh. yeah relatively ancient API, the docs say it was invented 6 years ago
Hm, json was still popular back then
Anyway yeah, good luck, sounds like you're gonna need it
man, I wish it was JSON
When u worked for fexco, they actually had me translate a Western Union backend app into node as a proof of concept
I had to write this thing to translate their XML into json
The whole office uses json now lol
heh, the wild wild west of ancient companies in ancient industries
Indeed
hola. I'm trying to figure out what kind of system I'm trying to build, or if there's a name for it; or whether I'm doing a bad thing.
I have a bunch of nodes which each produce records of contacts (myname, theirname, time). These records all exist in the same universe/scope/table.
... (see lower message)
@obtuse lance You only need to store a table with those values?
Yes, I only need to store those values; doesn't even need to be a table, and the time isn't reliable, so storing it is optional.
(I related it to tables/SQL because that's the vocabulary I have on hand.)
The DAG thing I imagined was a directory+file structure, files named $theirname with contents $myname $time.
So you're mostly concerned about syncing?
Have you considered writing your own program for this?
Yes, which is why I'm happy to accept relevant reading material :p
I dug into doing it something similar at one point and got way over my head very quickly
Well, I don't know much about databases but I do have suggestions for keeping multiple machines in sync
(inotify+cron)+rsync? ;p
I was going to suggest writing your own syncing code, but rsync would be better for the actual transfer of data
correction: probably will need to write my own implementation because the target audience.
so yeah, I go directly back to DAGs and stuff
rsync seems like a run-away idea
your own implementation should work fine as long as they aren't changing the clocks on their machines constantly
I was going to recommend that a machine checks for other machines on the network, then checks offset between the network clock and their own clock and fixes that, then uses the adjusted time for checking sync
right, so, you're losing me.
I'm not any closer to understanding how to do that
also, no. Clocks are like timezones, I'm not fucking touching them with Dundee's knife if I don't have to.
Will entries ever be removed from the list?
yes (but in a DAG it will be another node appended to the tree so it won't matter?)
I can sorta do databases, but I have zero experience in networking, so I doubt my ability to help you
oh well, thanks for the time ;p

repeats down here
hola. I'm trying to figure out what kind of system I'm trying to build, or if there's a name for it; or whether I'm doing a bad thing.
I have a bunch of nodes which each produce records of contacts (myname, theirname, time). These records all exist in the same universe/scope/table.
I very very much want to avoid any centralized database or control because the target audience doesn't know how to keep track of the central machine. I'm uninterested in "security" because of the audience.
I can't rely on machines having reliable clocks, at all. I have also found that I can't use leaderless consensus because nodes will appear and disappear, and I cannot guarantee that any number of nodes will be online or that they won't otherwise meet in other network partitions.
I have thought about using git/DAG model: Each node is the owner of a DAG. Any node can provide updates for any other node. It avoids needing clocks to order events.
Using different DAGs means I would have to "coalesce" all trees to create the "universe/table," but I believe that is a very lightweight operation. Conflicts aren't a problem for me in this case.
I'm not sure what this is called, or whether there are downsides to this option, or whether it's realistic.
I would appreciate advice, or a general idea of what relevant stuff I should read up on :D
Perhaps take a look at the "spanning tree" model
Another option would be to look at how MongoDB does replica sets
Spanning tree model for syncing data? I don't need to ensure efficient sync, so that seems like run-away, orthogonal, unnecessary complexity.
You lost the opportunity to avoid complexity by having requirements that prevent you from having a central node
Certainly, however the client can use multicast without caring about STP. Can you help me understand what about this complexity makes it necessary in this situation?
You don't have a reliable clock
If you had a central node, that wouldn't matter at all
You can just get the time from it
I'm not really sure what audience you're working with either
Not caring about security suggests that they have the expertise to set up a closed intranet for their nodes
But you suggest that that isn't the case by saying they can't take care of a central node
Their needs are simple and security is simply not one of them. They are not experts of any kind :p
I'm not with you on why not having a clock leads to STP. Can you take me there?
Well, I didn't actually tell you to use STP, I suggested some research possibilities :P
but not having reliable time is very.. 90s
any kind of crypto is going to need that, as well
I'm so confused by what you're thinking of.
There's no crypto involved whatsoever
DAGs (if you're talking about that) generate hashes, which don't rely on clocks, much less sync'd clocks.
And I still don't understand what aspect of STP you're suggesting is relevant to this situation? :/
The problem is that I don't really understand your requirements, and you may be expecting a full-on solution as a suggestion here
the reality though is that for something like this, the most you're gonna get from most developers are semi-relevant topics to do research on
because the situation you're describing appears to be incredibly niche
You also seem to already have some kind of implementation detail in mind
Right, I do have a possible implementation in mind, because an implementation is my goal; given the restrictions I'm aware of :p
I am trying to work backwards and forwards because I feel that I'm missing some fundamentals to know what it is that I'm building.
I don't understand how you connect STP and this situation. In what way is STP semi-relevant to this situation or potential implementation?
I can learn from that answer. I can't really learn anything useful from reading the STP RFC with no goal.
The point is that you need some way to get every node connected together
In most situations, having every node update every other node is very inefficient and could slow the application down
having some kind of hierarchy is important in that case
premature optimization.
You're telling me you'd be happy to rewrite the entirety of your networking code later? :P
Are you stuck on python 2?
Like I said, I'm not sure how, or if, STP helps me understand a fundamental design idea which I could use for syncing a bunch of records produced by byzantinely available, independent nodes.
Then don't use it, I guess
I'm asking what about it you connected to this situation
It's a confusing suggestion to me
I mean, I explained as best I could
At this point I'm really curious about the reasons you went to STP?
I don't really think I can explain it any better than I have, sorry
okay :p
@obtuse lance Will the number of machines in use change?
yes
(so precluding raft/paxos ;p)
I might be super dumb. If each node is the author of its own records, and I'm just coalescing the records from each node to create the "universe," I don't need trees or dags to keep history. I can use a per-node version number and always prefer the higher one when syncing.
Sweet, this got easier for me
here's some pseudocode I made
#retrieves locally stored ledger of machines to connect to as well as a locally stored version of the info to be shared
ML = GetLocalMachineList()
L = GetLocalInfo()
#Attempt connecting to each machine then retrieve a global list of connected machines when a successful connection occurs and update it with itself.
#Also gets a current version of the list
for machine in ML:
if AttemptConnection(machine):
ML = GetMachineList(machine) + GetSelf()
GetInfo(L)
Pushupdate(ML)
break
I appreciate it :D
Again, I have zero networking experience
There would also be removal of machines who disconnect for too long, and a backlog of all connected machines.
I forgot to do a clock thing
I did have something on mind
also keep in mind that ML is sorted from oldest to newest in terms of connection time.
#requests the global time from the oldest machine, then generates an offset amount. RequestTime is ping adjusted as well.
GL = time.time() - RequestTime(ML[0])
def Time():
time.time - GL
catalogue = { 'node_id1': Logs(version=10, data=...) , 'node_id2': Logs(version=187, data=...), ... }
sock = socket.open($multicast)
while 1 {
recv = sock.recv()
if recv:
recv = process_magically(recv)
if recv.type is ADVERT and catalogue[recv.node.version] < recv.version:
sock.send(build_request(recv.node))
else if recv.type is REQUEST and catalogue[recv.node.version] > recv.version:
sock.send(send_log(recv.node))
else if recv.type is LOG and catalogue[recv.node.version] < recv.version:
catalogue[recv.node] = Logs(version=recv.version, data=recv.data)
sock.send(advertise(catalogue))
time.sleep(1)
}
an advertisement will cause a flood of requests and subsequent flood of logs, but this is the basic idea I have now
thoughts?
Feels like I might be reinventing a wheel
instead of sharing the information directly, why not share a list of changes. That way, removal of entries and simply being out of date would be separated
You most likely are.
Because diffs are hard and add complication :p
I could do it if trees, but I might as well just cache the last 10% of versions to do diffs against.
LOG_DIFF packets would be easy to add
Yeah, so I'm curious if there is a name for what I'm trying to do :p
blockchain
it's a decentralized ledger
Requires a dedicated number of nodes and is a mitigation against lack of trust
I can't guarantee enough online nodes to prevent a split, and I have trust
you said you didn't care about security
There might be a way to adjust behaviour to prevent splits
Right, I can trust any potential node, so I don't care about security
Modifying blockchain implementations to avoid forks seems super scary, especially since my understanding of how it deals with forks is to discard all but one by design.
it was partially a joke
but you should try searching with the keyword "decentralized"
Cool!
MongoDB or PostgreSQL?
What would ya guys recommend
Its about an application that's currently relatively small
but we would prefer to not ever have to move to a different DB
isn't mongoDB sharding hellish or smth?
Not needed in most scenarios
hm so what would you recommend?
Out of the two, I like Mongo, but that's personal preference
I use RethinkDB primarily and Mongo is closest to that
Anyone know a good step-by-step or tutorial for MySQL and Flask? I'm comfortable with python and have a fair grasp on flask now. I know SQL but only have used MS access.
you could go for https://www.sqlalchemy.org/ or https://github.com/PyMySQL/PyMySQL they are the two most poular for that i guess, although i would recommend to at least go for postgresql and https://pypi.python.org/pypi/psycopg2/2.0.4
Thanks, I'll take a look
@warm hare use an ORM so you don't have to worry about switching databases.
SQLAlchemy for Python, PHP has one built in, Diesel for Rust, ActiveRecord for Ruby
there's an orm for like every DB nowadays
Pick one. It's not like your choice of database is important to you since you just asked whether you should use <Document> vs <RDBMS> without outlining what your data looks like, so maybe you shouldn't use a database at all.
At the very least, an ORM leaves you in a position to make a less invasive change if you find out the approach to databases you took was the wrong one.
is it possible to generate .sql scripts from sqlalchemy somehow?
sorry, I should've been more specific, I meant doing this but for creating tables depending on dialect
because you create tables through Base.metadata.create_all(engine)
Does the last section not meet those needs?
"If you want to take a peek at what is going to be sent to the DB, you need to tell the SQLAlchemy compiler what dialect it should be using. Here’s a way to print exactly how it’s going to be compiled to:"
I'm not familiar enough with it to know, but I imagine the resulting CREATE can be inspected as well.
Hmmm, I‘ll see what I can do
@ionic pecan
Not sure how helpful that link is, though
It's horribly formatted on mobile
Thanks, thats just what I needed!
neat!
Are there any major differences between SQL Alchemy and SQLite3?
I wanna start getting into usage of SQL, but don't really know where to start.
There are also no pinned messages, so I can't check those for information
Alright, after literally 3 minutes of searching, I've found out that they're almost 2 different things.
A better question now would be to ask if I should just learn how to use SQLite3, or if I should incorporate SQL Alchemy into my learning of SQL.
first learn the basics of the language then think about how you will use it
but for the learning process itself sqlite would prbly be easier to use
Thank you very much.
Sqlalchemy is an ORM
You write code using objects and query those objects, and Sqlalchemy takes care of the SQL for you
Which means that you can swap out the database type at any point
Anyone got a good resource recommendations for getting started working the python and mysql?
Uuh .. Dont work with mysql use postgres and for that u could take a look at psycopg2 or sqlalchemy. if u still want to start with mysql use pymysql or sqlalchemy
@trail imp
Alright, ty. Why are you saying not to work with mysql?
Oh, dude, so many reasons. Mostly silent data loss. Nonstandard behavior is a legacy of mysql.
^^^^
Change your schema? We'll fill in your new NOT NULL column with system default data for you! We're so helpful for filling out your age field for you.
Did something go wrong in this transaction involving your schema change? We'll just silently commit it.
It's fucked. It's so fucked.
They've done a lot of work to improve the situation. I don't think they just silently truncate data any more if you insert longer decimals than the schema says it stores, but there's plenty of reason to prefer postres or maria.
@tropic zealot If you want to learn SQL itself dont use SQLAlchemy, the point of the ORM is to handle things through objects and methods and not actually write SQL itself
...that was from about a week ago, and I already got what I needed explained to me...
lmao
Oh shit true, it wasnt scrolled down so i didnt notice
You could have said it in a nicer way however, i was only trying to help
^
still useful to have a tl;dr
I have a function in postgres that has return type table. This table returns rows of username, firstname, lastname, sessions etc (username is in a different table). I need the column names and data type of the return type table. So that I can use those column name and datatype inside django rest framework. Any idea how can I get the column name and type of a function that returns a table?
anyone here work with Mongo need some help
I am running into an issue where If I want to insert 100 documents into 100 different respective collections, so one doc per collection. The doc size is not huge either about 10 fields and none of them are huge largest value is the unix timestamp. the run time to do the 100 inserts is taking about 30-40 seconds it seems to be way too long. I am curious if this is even the correct way to be using mongo, or is there a way to like commit the cursor like in sqlite to eleviate the call stack.
I am not doing anything that hasn't been done before, it just seems like the driver is struggling
@ornate abyss knows mongo
ty @ionic pecan
from pymongo import MongoClient
data = urlrequest // 100 item json
client = MongoClient()
db = client['test-database']
for i in xrange(len(data)):
db[data[i]['name']].insert_one(data[i])
thats basically it
Problem is solved, it was my inexperience with mongo turns out initializing the collections for the first time takes some extra time I wasn't expecting.
I have some data that I'm gonna be updating and using in a Discord bot that I'm writing for my friends and I. This data is going to be containing things like D&D character sheets. I have a format in JSON already created, but I was just wondering just to wonder:
Would it be better for me to move to SQLite3 for something like this or to stick to JSON? IIRC, we're gonna have about 10-15 people playing max.
Just for reference, here's what I have in JSON:
{
"name": "null",
"age": 0,
"race": "null",
"class": "null",
"religion": "null",
"stats": [
{
"strength": 0,
"dexterity": 0,
"constitution": 0,
"intelligence": 0,
"wisdom": 0,
"charisma": 0,
"luck": 0,
"speed": 0
}
],
"experience": 0,
"level": 0,
"background": "null",
"alignment": "null",
"languages": [],
"hit_dice": "null",
"hit_points": 0,
"proficiencies": [],
"saving_throws": [],
"abilities": [],
"skills": [],
"gold": 0,
"initiative": 0,
"perception": 0
}
using flat-files to do data storage, manipulation, and recall is reinventing the wheel.
I doubt you're going to suffer for having the extra weight of an sqlite import, and it's going to make far better choices than you would about the data
It isn't necessary. You can run facebook on flat files if you're really really determined; but it's not like you gain anything from avoiding the extra bit of work to interact with sqlite, which means you now get a decent effort at protecting your database from application crashes for free.
to be clear
sqlite is still flatfiles
unless you're using an in-memory database for whatever reason
but yes, it's certainly a better option than rolling your own
sqlite store is a filesystem.
You can say your rootfs is also a flatfile since you can just copy it into a file or so, but just because it's in a file there doesn't mean it's not still a filesystem :/
the difference between that and rootfs is the kernel has support for rootfs
wat
well, unless you're on windows
As if FUSE fs's userspace filesystems aren't "real" filesystems, bro?
I mean, they're not, technically, but they're as good as
(EDIT: Message was edited after I replied to it)
No, dude, they are.
sqlite is not implemented that way either way, if memory serves
Filesystem is a specific structure, it's not decided by whether the kernel supports it.
I don't think sqlite is a filesystem whatever way you spin it, honestly
I'm pretty sure it's just a paged/segmented file, no?
that's what the documentation says, assuming sqlite.org is the site to find that
...
The main database file consists of one or more pages. The size of a page is a power of two between 512 and 65536 inclusive. All pages within the same database are the same size. The page size for a database file is determined by the 2-byte integer located at an offset of 16 bytes from the beginning of the database file.
filesystems by definition are systems of files
pages are not files
by that logic, any segmented file is a filesystem
my GIF avatar is a filesystem
yeah, not once does the sqlite documentation call the format a "filesystem" either
If you're not willing to explain yourself, don't make the assertion lol
I looked up the documentation, that's what it says
Why do you feel that sqlite is a filesystem?
...so I'm guessing I should attempt to migrate over to SQLite?
You're not willing to explain your ridiculous idea that what qualifies something as a filesystem is whether it's supported by the kernel. You have no room to talk.
This entire debacle sparked off of me asking a question.
I later corrected myself by giving the definition of a filesystem
If that's how you think conversations work 🤷
You're the only one being confrontational here.
You're the only one being frustrating here
You need to take a step back if you can't control your own mood over something as trivial as this.
(I even already left this alone. What are you on about anyway.)
It's a simple question
No
You seen convinced that sqlite is a filesystem - why?
This is silly.
Hmmm?
Wait
Are you interpreting that in the least charitable, most literal sense? Is your entire "just a question" based on a forced misunderstand? From the guy who said that SQLite is flat files comes the interpretation "databases are filesystems"?
You made that assertion, but from what I can find, a filesystem is simply an abstraction of data using "files", and the sqlite file format documentation doesn't mention it
So I'm curious, it feels like I'm missing something
Programmers argue about semantics all the time :P
It's barely even related to what I asked 😛
Well, the answer is yes, you should move from what you have to sqlite
Our discussion is separate mostly :P
Our discussion argument is entirely irrelevant to your concern.
You should use sqlite for the reasons outlined 2 buffers ago
upps wrong channel
No, that is the opposite
but the part about getting django models to be used in scrapy
import os
import sys
# DJANGO INTEGRATION
sys.path.append(os.path.dirname(os.path.abspath('.')))
# Do not forget the change iCrawler part based on your project name
os.environ['DJANGO_SETTINGS_MODULE'] = 'iCrawler.settings'
# This is required only if Django Version > 1.8
import django
django.setup()
# DJANGO INTEGRATION
## Rest of settings are below ...
wouldnt be a good solution at the point where i setup the website on a server?
it appears to me that this solution is way easier so i could handle all my Database communication inside each Spider
but i might be missing a crucial part of possible problems later on
@viral crag
is it cuz i should not interfere with the django.setup() while its running
or that i should always avoid doing this to django?
I'm trying to complete sqlites tutorial didn't understand this part https://vgy.me/ZwOOmj.png
How do i actually connect to the database?
Do i have to add sqlite3 to the PATH?
don't think sqlite has their own GUI tool
that was linked in the manpage, I suppose that's supplied when you have sqlite installed
db browser for sqlite looks simpler ill go with it
Cardium requires a gui. For now
Did you just talk in third person
On a scale of slow to fast, what is the speed in which Python reads through .db files with SQLite3?
that's shitty scale. why don't you time it?
🤔
I don't think I follow.
I also don't think I've started with my database, yet, which is why I'm asking about speed now.
to give you an answer that makes the same amount of sense as your question:
"Eeeeeeeh."
Okay...
I'm also gonna guess that lemon was referring to this https://docs.python.org/3/library/timeit.html
when he referred to "timing it"
it's a popular module
what are the disadvantages of pickling a dictionary for data storage over traditional databases such as SQL, aside from compatibility?
Well dicts aren't implicitly persisted
the comparison doesn't really make sense on its own
implicitly persisted?
I mean, the whole point of a database, surely, is that it's saved
it's not just stored in memory
I ask this question because I witnessed an argument over what someone should be using for their large-scale web application in python
ah, so instead of loading the whole thing from disk it's just fetching sections in sql?
I'm not too familiar with the methods that sql uses myself
they'd mentioned having the option of pickling a plain dict, using CSV, or using SQL
I mean, large-scale pretty much requires a database for most tasks
You can't just have a single process with a dict in it
pickling and CSV creation are just means of dumping a Python object into a file
because those objects can get large, and to avoid the issue of needing to manually dump periodically to keep your data safe, you use database software to curate efficient access to it
SQL stands for Structured Query Language
it's a language commonly used to access relational databases
not any particular piece of software
so like G said, databases are kinda required for large scale applications with lotsa data
file dumping gets problematic quickly
What's the best way to schedule an event for a potgres db? Basically I need to trigger a function of some sort after an INSERT into a certain table that will send a text (Twillio) two hours after the INSERT took place. (I'm using psycopg2)
@raw zenith
Honestly, the easiest and fast way is a cron job that runs every 5 minutes. Make sure your table has a column "notify" and "date created" so that the script knows when to send a notification.
When your cron job runs it selects all rows notify=0 and date_created more than 2 hours ago. after it sends the notification it sets notify to 1 (or true)
Heavy handed way is to use celery or python-rq
im trying to make a monitor and its done but im stuck on the final thing creating and maintaining a databse, so i made one in json and made it so that it checks if its new data or not, now how do i append the database file
hello
nvm
b
c.execute("INSERT INTO mesajlar VALUES(message.content, message.author, message.timestamp, message.author, message.author.top_role.name, message.author.voice_channel)")
sqlite3.OperationalError: near ".": syntax error```
Can you guys see anything out of order?
yup
you need to pass the message attributes separately
sqlite doesn't know what message is
c.execute('INSERT INTO table VALUES(?, ?)', ('dank', 'memes'))
so i write message and stuff on right?
thanks that did it
btw
do a search on that page for 'parameter substitution'
that should be standard for any sqlite insert that uses any user submitted content
the questions marks aren't just placeholders for variables
oh so now im secure
wow and im logging messages directly someone could mess up easily
i wouldn't go that far, but now you're more secure than just passing user content
right
ala "sql injection"
oh god
you're logging user message content too
good thing parameter substitution was suggested
yeah im not planning to use it for long but i could use something in the future and fuck up big time
should i assign them to a variable first as its suggested or is it the same thing?
Using ? parameter substitution is fine, yeah
❤ thank you
anyone ever have issues with aiomysql and queries wrongly returning no results like half of the time?
ive checked my db through mysql workbench and used the same sql queries and got the correct results 100% of the time
im using a connection pool with autocommit set to false
setting autocommit to true seems like it might be fixing the issue but it also slows down performance a ton
What do you mean it's wrong returning no results
Do you mean it's not returning data you recently inserted?
It will return no tuples despite there being a matching record in the database. If I copy the query in the code and run it in MySQL work bench, I get the right result
I've been looking back into databases again (seeing as how I'm going to be using one for my Discord bot), and have come to the conclusion that I'm going to have to use eithr MySQL or PostgreSQL in order to perform my database queries. I, however, don't know which to go to. Do any of you have suggestions that would lead me to one or the other, based on the databases themselves, or the async modules that they run off of in Python?
i've heard that you should use sqlalchemy-aio with discord bots
I've heard around the grape vine that people shouldn't really learn SQLAlchemy if they don't know SQL, since it deprives them of other useful knowledge. I'll take it into consideration and look into it, but I'm just putting that out there.
alrighty
SQLAlchemy is not yet suitable for asyncio
I would suggest using a database that has a driver that is, such as rethinkdb
Not much but yeah
a b s t r a c t i o n s
@tropic zealot a choice between MySQL and postgres go with postgres
Why do you need to use NoSQL?
NoSQL?
I don't know what that is.
I'm looking for a database to store user information that I'm trying to collect. Don't want multiple JSON files in a storage bin, so I figured a database would be nice. Need something Async, which means only certain kinds of databases, along with their async libraries, will workfor the project.
I might just try rethink and move onto something else if I don't like it.
NoSQL is a term used for when the database doesn't use SQL and is non-relational
Does anyone know if its possible to INSERT and SELECT in the same query with pymysql? I can execute a query like
SELECT LAST_INSERT_ID()```
in mysql workbench, and I get the return value I expect. If I execute the same query in pymysql through the cursor, nothing seems to be returned
I was also considering switching my program to use postgres. Decided not to since it seems a like a bit more work, and I can accomplish what I need with mysql. If this is a solution that can be more easily solved with postgres, I'll probably switch since I will need to tackle this on multiple occasions
you do terminate the second line with a semicolon too, right? SQL likes semicolons.
added the extra semi, still no luck
also this isn't really doing insert and select in the same query, this is doing them in two separate queries. any database should be able to do that, but I have never actually used pymysql so I don't know how particular it is about that sort of thing. it strikes me as odd that it wouldn't work.
have you gotten any query to work so far using pymysql?
Yeah. if I execute that query, the insert is successful if I check the table, just the return doesn't work
can you return without the insert?
perhaps you're just not reading the return data properly?
Im just printing the raw cursor.fetchall()
seems to give me the right data on other queries
right, so it's just these multiqueries that are turning up blank?
hmmmm.
@shy magnet apparently there's a executemany method
try that.
Ill check it out. thanks lemon
no problem, guy
I'm using js not python, but with sql-ing, what's wrong with "UPDATE USERS SET Name='" + String(newname) + "' WHERE UserID='" + String(userId) + "'"
not using parameter substitution
unless String performs some cleanup
maybe missing a semicolon?
@torn sphinx Don't just insert strings like that, you're leaving yourself open to SQL injection exploits
in js sql injectsion exploits don't happen from inserting strings like that
not through mysql
equivalent of str()
yeah
thanks!
i don't know which sql library you're using but you should be using parameter substitution for this
ok...
im using mysql.. but i'll find a colution
*solution
now no exploits: newname.replace("'", "").replace('"', "")
well u know
newname.replace("'", "").replace('"', "")```
@torn sphinx Don't be that guy
Do it properly using the parameter substitution of the library
Or don't do it at all
No, it doesn't.
why not?
Your attitude is appalling mate, there's no reason for you to think you know better than the library devs when it comes to security
no i know im not better
This is a completely solved problem
And people doing it themselves is exactly why we have problems
The library will solve this problem for you.
no i know you can do it with the library
And it's far simpler than what you're doing, most likely
but it's just more effort and complex
If spending 10 minutes reading the docs is too much work, then you're in the wrong field, mate
look i think im fine, if someone really wants to exploit me they can
i really am not that uptight about security
thats all
You should be.
but it's not that important
There is a current epidemic of software that people are using with these kinds of exploits
They're rookie mistakes
But they are making the overall software scene very tricky to deal with
People don't know who to trust, and developers are finding it harder to get their software out there as a result
Yes, many projects are written by hobbyist developers
look, it won't make any difference to the world of devs
Probably a majority tbh
i just do this for fun, spare time, barely do anything with it
And if/when you get used to it, make your own public project or get a job in it
The fact that you have no idea how to do it correctly will come back to bite us all
it is public but it's just a discord bot
I'm not just talking out of my ass by the way, this is a thing that happens
If you're gonna learn to do something, do it right the first time
That's all
i mean if someone want's to change their name just to exploit my bot idc...
i understand
i am doing it wrong...
but it's fine at this level
for example my other project, which is bigger and in python, does do it the "right" method
i just don't want to be doing that with every single thing
Sorry, but I would not use your bot in this case
When someone could change their name and potentilally delete or leak my data
I'm sure many people would feel the same
but they can't really..
what am I reading
they can't "leak" your data
Text on discord
in the time you've spent discussing this you could've already changed your code to just work the right way multiple times
i am using some basic safety: .replace which is fine by me
that's not "basic safety"
no i can't it takes ages to restart
what I gave was just a dumb example
just find (whatever mysql library you're using)'s docs and find parameter substitution
Use pymysql
Friends don't let friends write insecure code
ive used it before its nice
im doing it in js, but thanks
what the fuck
@ornate abyss knock it off
knock what off
lol, calm down
i aint angry dw
ok u know, what ill use parametrised thing
but ill only restart like tomorrow
happy then @viral crag @ionic pecan ?
im just confused as to if you're using js why did this conversation even start
it's not my app that's vulnerable, so I don't really care. i'd be happy if you would see why it's useful instead of doing it because we've been telling you to
well, i understand it's security reasons
but i don't see what more they'll do than replace the ' and ", but i guess im not a big dev
im using that
Using a prepared query means only one keyword will be executed, if you do your method, thats simply a work-around, meaning that it can still be exploited via other means
let q = "UPDATE USERS SET Name= ? WHERE UserID= ? "
var query = connection.query(q, [newname, userId], function (err, results, fields) {
if (err) throw err;
});``` there done
that didnt take long
also no passwords are stored
also it takes about 15 mins where my bot is offline now
trying to turn on
it takes 15 minutes to turn on?
yea the host restarts
finds a server and stuff
sql is just so bad in general
it should be like changed completely
the concept
although, i don't offer any btter solution
bcz im me and im bad
i hv exams in a week, and here i am editing my bpt
*bot
SQL is very good tho
Both GDPR and the discord terms of service smile upon you @torn sphinx
lol 😄
oh dear.
Haha, hi lemon
hi 
4 hour discussion on whether or not to use parameter substitution in SQL.
this is why we can't have nice things.
:^)
"whether or not to use parameter substitution in SQL"
What's the alternative?
This is parameter substitution right?
INSERT INTO <table name> VALUES (%s, %s)
then cursor.execute(sql, (value one, value two))
Just wanna make sure
I'd say so, yes.
Ok thanks
"Linear search and binary search are the basic algorithms for implementing select operation. If the tuples of a relation are stored together in one file, these algorithms can be used to implement the select operation. However, if indexes such as primary, clustering, or secondary indexes are available on the attributes involved in the selection condition, the index can be directly used to retrieve the desired record(s)."
this is from my database book
what does it mean when it says "indexes such as primary, clustering, or secondary indexes are available on the attributes involved in the selection condition,"
Im assuming this is answered since you asked the same question in the other discord
anyone got any idea of how to return the position of a specific entry? pretty new to python and sql
but say i have 500 entries with unix timestamps and i have an identifier for each
i want to find the "rank" of that unix timestamp by using the identifier and descending/ascending order
how would i do it?
right so i'm setting up a discord bot linked to a sqlite3 database
if it's an SQL-based database, you should have access to ORDER BY
so eg ORDER BY column ASCENDING (or DESCENDING)
that's as part of a larger SELECT query
gotcha
it's just whenever I use select I only know how to set it up so it returns a single value
so eg, something like SELECT id FROM tablename ORDER BY column ASCENDING
you should end up with a cursor object you can iterate over with a for loop, or you can exhaust the iterator into a list by list(cursor)ing it
i dig the idea of the for loop
so that'd be something like for row in cursor:
take all entries, for each one add 1 to a value, and compare it to the requested ID
then i have the position when the for loop actually finds the ID
thanks man, appreciate the help 😄
No worries
Hey Pythonistas, I'm new here so Hi everyone !
I'm really needing help on an sqlalchemy-graphene problem, is there someone here that could help ?
Here's my database automapping :
engine = create_engine(" blablabla", convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base = automap_base()
Base.prepare(engine, reflect=True, generate_relationship=_gen_relationship, name_for_scalar_relationship = name_for_scalar_relationship, classname_for_table=camelize_classname, name_for_collection_relationship=pluralize_collection)
Buyer = Base.classes.Buyer
Base.query = db_session.query_property()
I didn't show the naming functions because it's heavy and not important for the problem (i guess)
And here's my schema
import graphene
import json
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType
from database import Buyer as BuyerModel
class Buyer(SQLAlchemyObjectType):
class Meta:
model = BuyerModel
interfaces = (relay.Node, )
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_buyers = SQLAlchemyConnectionField(Buyer)
schema = graphene.Schema(query=Query)
Produces this error :
AssertionError: You need to pass a valid SQLAlchemy Model in Buyer.Meta, received "<class 'sqlalchemy.ext.automap.Buyer'>".
The problem could be linked to the fact that graphene updated to 2.0 but i could find any clue in the docs
Anyone know a good link or website for editing jsons for things like "Phone List" or "player name and ID"
if i'm running a discord bot that connects to a DB does it make sense to be opening and closing that connection per command?
or should I just be committing the changes as the bot edits stuff
You should probably open and close the connection any time you wanna do something.
I think for something like a discord bot, keeping the connection open for the entirety is a better option. Creating a connection to the database takes time, and you dont want to be opening and closing say every message.
It really depends on the amount of queries you are going to be making
Is there anyone here who has experience with manipulating csv files in python?
I'm sure a number of people do! do you have a particular question about the topic?
Oh, I moved it to the python subfolder. Last time I asked I did not receive a response and do I'm hoping I would get a response and I did
😊
@neat arch what is the actual issue
I have two tables and want to select some data
I only want to get the data from table 2 if a row in table 1 has a certain value
what's the best way to do this and is it possible in one query
hope that makes sense
Kinda like that ^
But es fine i think I know to resolve it
Will let know if there are issues
@stray zodiac use a join
Could you perhaps explain a little more? I looked into joins but wasnt sure which one to use/how to go about it
ty for helping 😛
Well, im assuming the tables are linked via some sort of foreign key?
yeah they are
So, can you provide the schema
so i can get a better idea of what you want to do
But from what i gather, you would do an inner join on where the id = foreign key AND table.column = "some val"
np
So I have two types of questions, multiple choice and single answer
I want it to only get the options from the Multiple_Choice table if Questions.style is multiple choice
SELECT option1, option2, option3 FROM Multiple_Choice INNER JOIN Questions ON Multiple_Choice.question_id = Questions.id AND Questions.style = "multiple choice";```
Assuming the text within style is "multiple choice"
Np :)
So here's what I have from your help
SELECT Questions.text,Questions.answer,Multiple_Choice.wrong_answer1,Multiple_Choice.wrong_answer2,Multiple_Choice.wrong_answer3 FROM Multiple_Choice INNER JOIN Questions ON Multiple_Choice.question_id = Questions.question_id AND Questions.style = multiple_choice ```
the problem is that it only returns all the multiple choice questions, can i get into return short answer questions too
so basically if the question is multiple choice it returns 5 values (text, answer, option 1, option2 and option 3)
and if it's short answer it returns just 2 (text,answer)
You would most likely have to make two queries
Since the columns you are wanting to select are different
Glad I could help :)
Any good tutorials out there for learning good database structure practices?
I just finished the django tut and i'm working on my app. I realized i have no idea what kind of models i'll need XD
well, think about how it would make the most sense
for example, what data do you plan on storing?
how does it relate to each other?
just whatever you do, try to make sure your queries dont look like this at some point ```Py
Title.objects.annotate(entries_last_week=Subquery(Entry.objects.filter(entry_date2__gte=make_aware(datetime.datetime.today() - datetime.timedelta(days=7)), entry_title=OuterRef('pk')).exclude(entry_readability=False).values('entry_title').annotate(cnt=Count('*')).values('cnt')[:1], output_field=IntegerField()),).filter(entries_last_week__gte=5).order_by("entry__entry_date2")
its a whole science for itself tbh. And as long as you dont have big performance requirements that good database schemes are not really a must have
courtesy of @oak pelican
Again @ionic pecan
That is not my but django 1.11's fault
In django 2.0 it looks like
all_titles = Title.objects.annotate(
num_entries=Count(
"entry", filter = Q(entry__entry_date2__gte=make_aware(
datetime.datetime.today()-datetime.timedelta(days=7)
)
)
)
).order_by("num_entries")```
shhhhhh
from django.urls import reverse
from django.http import HttpResponse, Http404, HttpResponseRedirect, JsonResponse, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError, HttpResponseBadRequest
from django.core import exceptions
from django.template import loader
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login, logout
from django.core.exceptions import ValidationError
from django.core.validators import validate_email
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.db import IntegrityError
from django.conf import settings
from django.views.decorators.csrf import ensure_csrf_cookie
from django.core.mail import send_mail as original_mail
from django.utils.html import mark_safe
from django.db import models
from django.contrib.auth.models import User
from django.utils.timezone import make_aware
from django.core.mail import EmailMultiAlternatives
from django.db.models import OuterRef, Subquery, Count, IntegerField``` @broken linden
fuck me
Do these come built in
HOLY HELL
Is that real
oh and someone
is that a real thing
Yeah it would take me about a year two implement them all myself @broken linden
That's bad right?
nah
@zealous elk Nope
django has pretty much everything built-in, it's amazing
Yeah
@zealous elk Those are prewritten amazing codes which you don't have to write if you use django
If you use flask you have to implement them all
Meh, whatever
like the first three lines are stuff you dont even need to import in flask
everything else is there via the rich flask plugins ALSO this proofs my point right of django forcing you to do stuff the django way
@oak pelican
anyways, i'm going back to the start of my project because i need to learn how to do some TDD
but it's not really intuitive to me.
Does it ever become intuitive?
That doesn't force anything dude lol, you can import abstract classes of all of them and build over themselves, or you can even screw them and build anything freely
The only thing it forces is the base directory structure
pffffft
(python noises)
XD
omg
I never realized there was a war between flask and django
why not just use both
how
wolfturn
a nasty hyrbid
both parties would kill you for that
hybrid*
lol
LOL
its war
i'm gonna learn both eventually
You can learn flask
i hear flask is easier for quick and easy stuff
Because it is really simple
why do you want to learn django first?
Because its the harder one
So I'd suggest learning flask if you are planning a small project
lol
this is the first time i've used a professional level framework like this.
actually no django has more provided structures and clear ways todo shit
can i see?
I'd love to see what some actual views look like in django
(on the other side its someone...)
because i'm not sure how to structure mine yet.
That would never happen in flask because flask can't even handle that kind of website xD
So general views are pretty much the standard for django no?
11/10
wat
lol aight :D
@oak pelican which website show me
Dude I'm just kidding :D
but
as_view()
its wartime 😭
That thing
But it is obvious that it is easier to make a heavier website in django
That is for class views Wolf
Yeh, class views
(surpressing of long hmma)
If you want freedom you'd use function views
Function views. let me google that.
Classviews are pretty limited
@ensure_csrf_cookie
def index(request):
if request.user.is_authenticated():
styleconfig = UserProfile.objects.get(user_name=User.objects.get(username=request.user.get_username()))
title_count = styleconfig.user_title_pref
else:
styleconfig = None
title_count = 50
template = loader.get_template("mainsite/mainsite/index.html")
template2 = loader.get_template("mainsite/mainsite/index_logged_in.html")
context = {
"index_name": request.COOKIES.get("titles") if request.COOKIES.get("titles") in [*TITLECOOKIES.keys()]+[str(chn) for chn in TitleChannels.objects.all()] else "today",
"site_name": URL,
"all_titles": getlast(Title.objects.filter(title_channels__channel__contains=TitleChannels.objects.get(channel=request.COOKIES.get("titles"))).order_by("entry__entry_date2") if request.COOKIES.get("titles") in [str(chn) for chn in TitleChannels.objects.all()] else TITLECOOKIES.get(request.COOKIES.get("titles"), TITLECOOKIES["today"]), title_count),
"title_channels": TitleChannels.objects.all(),
"styleconfig": styleconfig,
"index_body": index_body,
"index_header": index_header,
"empty_title_list": empty_title_list
}
if request.user.is_authenticated():
returny = HttpResponse(template2.render(context, request))
returny.set_cookie("visited_index", True)
return returny
else:
returny = HttpResponse(template.render(context, request))
returny.set_cookie("visited_index", True)
return returny```
Here is my index
Don't mind that one line
"all_titles": getlast(Title.objects.filter(title_channels__channel__contains=TitleChannels.objects.get(channel=request.COOKIES.get("titles"))).order_by("entry__entry_date2") if request.COOKIES.get("titles") in [str(chn) for chn in TitleChannels.objects.all()] else TITLECOOKIES.get(request.COOKIES.get("titles"), TITLECOOKIES["today"]), title_count),```
oh gosh
Nice line isn't it
Why are there 2 templates O.o
(you will be happy if you know)
those functions are called "god functions"
See you in 10
Meh, i already built it
Just kinda threw it in there
if it doesn't work i'll go back out and start it over
if you use a system which makes sense to you and dont need high avaiability and performance stuff dont change it
eventually
WEll
this is a project i want to be able to put on my resume
so i'm trying to make it the nicest i can.
¯_(ツ)_/¯
so its like XD
but since i don't know what i don't know.
I might as well just do it quick and dirty and then find out what i did wrong i guess
i put the majority of shit on my github and in case i ever open a resumee ill prolly just generate a page out of all my github projects automatically regardless of them being shit or not
I'm gonna head out but before that I have to say this @zealous elk
if my github stuff is toooo shitty i delete it
Whatever you do
dont use django
Don't put your first project on a framework on your resume
I made this website as my first project
this whole resume thingy is so funny for me as a german tbh
It has like 4k lines of code
a resume does nearly not matter in germany from my experience
at least in programming
Yet I could've made it 10x more efficient with my knowledge now
🙆 ping
aaaah
@oak pelican Thanks, then i'll quick and dirty it and then use that to re-make it
i'll do test driven development later then.
I mean there are a lot of parts of a website
The messaging is a whole different part if you are gonna do a social media
The message app could take a lot of time alone
no messaging
API is another bitch
It's just a simple quiz + information generation i guess is what i could call it?
depending on your inputs
and saving a user.
not a lot
i mean @zealous elk look at it https://github.com/hargoniX?tab=repositories 2 of them are jokes, one is just editing a single word in a readme i didnt contrib to one even soo ¯_(ツ)_/¯
Your models are also another thing, you should really build your models neat if you are gonna have more than 4-5 models
My models suck in my website
ok
Yeah i'm kind of OCD
so that's why i wanted to learn models really well
so i could make them super neat.
Actually I'd share my website with you if I hadn't stole the html and css and half of the javascript
lol
lol
(he is lying there is no website)
XD
Thank you all
you guys are really motivating 😃
i'm switching from real estate to coding and its a really hard thing to switch to cold turkey so i'm glad you guys are around
i hope i can eventually make some money from this lol
been studying non-stop for about 3 weeks now.
i hope i can be good in 3 months.
I hope it works out for you :D
😃 thanks again!
ogod, that looks ugly, one sec
Projects.ProjectName as 'Project Name',
EmployeeProjectAssignments.StartDate as 'Start',
EmployeeProjectAssignments.EndDate as 'End',
(Employees.FirstName + ' ' + Employees."Last Name" + ' ' + CAST('Start' AS VARCHAR(25)) + ' ' + CAST('End' AS VARCHAR(25))) as 'Manager'```
That looks a bit better
how do i cast these two Start and End to work?
Anyone know how to retireve every nth document from a collection in mongodb? I want to process this on the mongo server not on my backend server
Is there any way to insert columns into a query statement by column number in a table instead of column name?
Like I'm trying to do here, by using col[1] col[2]:
c.execute('INSERT INTO {} (Date, {}, {}, Source, Headline) VALUES (?, ?, ?, ?, ?)'.format(table), (Date, col[1], col[2], Source, Headline))
No
Alright, that's what it seemed like on the internet too. No worries, thanks for the confirmation
np :)
hey guys
👋
im new to flask and im figuring out a way to connect to mysql
need help plz
mysql = MySQL()
# MySQL configurations
app.config['MYSQL_DATABASE_USER'] = 'jay'
app.config['MYSQL_DATABASE_PASSWORD'] = 'jay'
app.config['MYSQL_DATABASE_DB'] = 'BucketList'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
is it something like this?
should it come before
app=Flask(__name__)
or after ?
considering you need the variable "app" for it it would kinda make sense to have the app variable defined before using it
ok
Hi guys! Does anyone have a few minutes to help me out? I need to use a flexible way of connecting to a certain host ( postgress, SQLite, MySQL etc. ) and create tables, and populate them.
I think a combination of a package called Munch ( Turning a list of dicts to objects ) and SQLAlchemy but i cant seem to get it to even connect.. Been using python for little over 2 months now so still new.
Any help would be greatly appreciated!
Well i learned that the SQLAlchemy needs to have a class or objects to parse and insert those objects into the database. But it needs to be generic ( i dont know what will be parsed, so tables must be made on the fly ) And munch is a tool that can create an object from a dict. But then again im new so i might be wrong.
So it can take a set of dictionaries, match them to a table and insert them too? Thats amazing. Thank you. Ill put some more time into it. Is there any other package that i might need to achieve this?
i don't understand what you mean with take a set of dictionaries
do you want to create tables from dictionaries?
I have a list, which contains dictionaries. And i need to find a way to connect to a database ( will be MySQL DB most of the time ) .. And some how create tables, corresponding to the keys of those dictionaries
And then populate the tables with the values of those dictionaries.
Well since im rather new, i dont know how to create classes on the fly ( which i thought you needed to create those objects, which Alchemy can use to store in the DB )
You don't have to make the classes on the fly
The idea is what you write the classes yourself
They provide a model which allows you to basically define what will be in your tables
Those classes are mapped to tables and instances of those classes are rows
You'll probably want something like Alembic as well
I understand that, although i dont know what Alembic is yet. The list ( containing those dictionaries ) are completely different everytime. And i dont know how to generate a class, containing those attributes which i can use as a model.
Well I don't understand why you would ever want to define your schema that way
But
You could probably use the lower level query building API
Or just literally generate the python code for the objects in like a string
dynamically generating tables sounds like a bad idea, imho
what are you trying to accomplish?
Well the idea is that a dataset is given, which can either be a two dimensional list ( or more dimensions ) , or a list containing alot of dictionaries which can be similar or different. The size can differ to from just a few dictionaries to hundreds or more.
When the set is given, it somehow needs to end up in a database. So credentials must be passed, and the dataset.
Then tables must be generated, and populated with the data inside those dictionaries or list.
I'm relatively new to python and i just found the alchemy package today. But i'm pretty stuck at this point.
Honestly this system seems too generic to be useful
Do you have any other suggestions?

👍