Sequelize-auto for SQLite - node.js

I'm trying to autogenerate my data models on sequelize for SQLite using squelize-auto on Windows. I have created my sqlite file with schema only, no data inside.
Also installed everything as indicated here.
The command I'm using looks like this:
sequelize-auto -h localhost -u dontcare -d "E:\full\path\to\my\database.db" --dialect sqlite
Also tried with some other path styles like './database.db' etc.
And this is the answer I'm getting:
Executing (default): SELECT name FROM `sqlite_master` WHERE type='table' and name!='sqlite_sequence';
Done!
After this, the script creates a folder called "models" with nothing inside.
Does somebody know what's happening here?
Many thanks!

I've found the problem:
-d should be the database name, not the path to the file.
For specify the file path, you should use the option -c indicating a JSON file. The storage attribute finally indicates that path.
The command should looks like this:
sequelize-auto -h localhost -u dontcare -d databasename --dialect sqlite -c options.json
And options.json looks like this:
{
"storage":"./database_file_name.db"
}
I hope this will be useful to someone.
Bye!

Related

Problem running bitbucket rest api command using python

I,am building a script to update files on Bitbucket using the rest api.
My problems are:
Running the command using subprocess lib and running the command directly on the command line gives two different results.
If I run the command using the command line, when I inspect my commits on the Bit bucket app I can see a Commit message and a Issue.
If I run the command using the help of the subprocess lib I don't have a commit message and a Issue in the end. The commit message sets itself by default to "edited by bitbucket" and the issue is null.
This is the command:
curl -X PUT -u user:pass -F content=#conanfile_3_f62hu.py -F 'message= test 4' -F branch=develop -F sourceCommitId={} bitbucket_URL".format(latest_commit)
The other problem is that I need to pass a file to the content in order to update it.
If I pass it like above it works. The problem is that I am generating the file content as raw string and creating a temporary file with that content.
And when I pass the file as a variable, it does not get the content of the file.
My code:
content = b'some content'
current_dir = os.getcwd()
temp_file=tempfile.NamedTemporaryFile(suffix=".py",prefix="conanfile", dir=current_dir)
temp_file.name = temp_file.name.split("\\")
temp_file.name = [x for x in temp_file.name if x.startswith("conanfile")][0]
temp_file.name = "#" + temp_file.name
temp_file.write(content)
temp_file.seek(0)
update_file_url = "curl -X PUT -u user:pass -F content={} -F 'message=test 4' -F branch=develop -F sourceCommitId={} bitbucket_url".format(temp_file.name, latest_commit)
subprocess.run(update_file_url)
Basically I'am passing the file like before, just passing the name to the content, but it does not work.
If I print the command everything looks good, so I don't know why the commit message does not get set and the file content as well.
Updated:
I was able to pass the file, My mistake was that I was not passing it like temp_file.name.
But I could not solve the problem of the message.
What I found is that the message will only take the first word. If there is a space and one more word after, it will ignore it.
The space is causing some problem.
I found the solution, if someone found himself with this problem we need to use a \ before the message= .
Example: '-F message=\" Updated with latest dependencies"'

Query does not work with documents

So I'm trying to curl some queries. I have 2 documents under a folder which objectId is 8e92c0d5-0fdc-4363-9922-51f9ba93af62.
If I query for the folder itself as in:
curl -uAdministrator:Administrator "http://localhost:8282/nuxeo/atom/cmis/default/query?q=SELECT+*+FROM+cmis:folder+f+WHERE+f.cmis:objectId+=+'8e92c0d5-0fdc-4363-9922-51f9ba93af62'" | tidy -q -xml -indent
I get the intended result.
However, if I query for the documents under the folder:
curl -uAdministrator:Administrator "http://localhost:8282/nuxeo/atom/cmis/default/query?q=SELECT+*+FROM+cmis:document+d+WHERE+IN_FOLDER(d,+'8e92c0d5-0fdc-4363-9922-51f9ba93af62')" | tidy -q -xml -indent
I get no results, even though there are 2 documents under it.
Is there some setting I forgot to turn on? Or am I doing something completely wrong here?
You should add &searchAllVersions=true to your URL. See the Nuxeo CMIS doc about the use of searchAllVersions in Nuxeo.

D2RQ parameters for generate-mapping

We are currently working on a project involving an "ordinary" relational database, but we wish to enable SPARQL requests towards this database.
d2rq.org is a tool that enables SPARQL to be run towards the database with the help of a .ttl file which defines the database to RDF mapping.
This .ttl file can be built automatically with a D2RQ tool named "generate-mapping".
http://d2rq.org/generate-mapping takes quite a few arguments, some preceeded with a single dash "-" and some double "--". My challenge is that any argument preceeded with a double dash generates this error:
Command:
./generate-mapping -u root -p password -o testmappingLocal.ttl --verbose jdbc:mysql:///iswc
Result:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown argument: --verbose
at jena.cmdline.CommandLine.handleUnrecognizedArg(CommandLine.java:215)
at jena.cmdline.CommandLine.process(CommandLine.java:177)
at d2rq.generate_mapping.main(generate_mapping.java:41)
Any help with the double-dash arguments will be greatly appreciated.
OS: Ubuntu Linux, D2RQ version: 0.8
D2rq and mysql database using generate mapping file & rdf files.
1).mapping file generate commands:
./generate-mapping -u root -p root -o /home/bigtapp/Documents/d2rqgenerate_mapping/mapfile.ttl jdbc:mysql://localhost:3306/d2rq
note: 1. root -p root -> mysql db username & password.
2. /home/bigtapp/Documents/d2rqgenerate_mapping/mapfile.ttl -> file save output path .
3.jdbc:mysql://localhost:3306 ->mysql driver.
4./d2rq ->database name.
2).the mapping file using RDF creation:
use following command.
The RDF syntax to use for output. Supported syntaxes are “TURTLE”, “RDF/XML”, “RDF/XML-ABBREV”, “N3”, and “N-TRIPLE” (the default). “N-TRIPLE” works best for large databases.
command:
./dump-rdf -f RDF/XML -b localhost:3306 -o /home/bigtapp/Documents/d2rqgenerate_mapping/dumpfile.rdf /home/bigtapp/Documents/d2rqgenerate_mapping/mapfile.ttl.
apache-jena-fuseki create dataset then rdf file uploadserver then your using sparql query ..you get the result...

PostgreSQL import file

In PostgreSQL and bash(linux), are there ways to directly import a file from the filesystem like
[execute.sh]
pgsql .... -f insert.txt
[insert.txt]
insert into table(id,file) values(1,import('/path/to/file'))
There seems to be no import function, bytea_import as well, lo_import would save int and I don't know how to get the file back (these files are in small sizes so using lo_import seems not appropriate)
And can how do I move the insert.txt statement to PostgreSQL?
I'm not sure what you're after, but if you have script with SQL-statements, for example the insert statements that you mention, you can run psql and then run the script from within psql. For example:
postgres#server:~$ psql dbname
psql (8.4.1)
Type "help" for help.
dbname=# \i /tmp/queries.sql
This will run the statements in /tmp/queries.sql.
Hope this was what you asked for.
In case of more detailed parameters:
$ psql -h [host] -p [port] -d [databaseName] -U [user] -f [/absolute/path/to/file]
The manual has some examples:
testdb=> \set content '''' `cat my_file.txt` ''''
testdb=> INSERT INTO my_table VALUES (:content);
See http://www.postgresql.org/docs/8.4/interactive/app-psql.html

Postgresql restore Error at or near "`"

I have 800mb backup postgresql db, i even had hardtime to open the file because not enough memory.
I tried to restore the file, but i receive this error while restoring, does any one know how to fix
I run this command:
psql -U root -d mydatabase -f dbfile.sql
i receive message:
ERROR: syntax error at or near ""
LINE 1: INSERT INTOcv_balance` VALUES (4279704,3431,'2008-08-10 2...
please help
It looks like for some reason, a ` mark got either added after cv_balance or removed before cv_balance - look on the first line of your SQL file, it currently probably reads something like this:
INSERT INTO cv_balance` VALUES ...(continued)...
modify it to read like this:
INSERT INTO cv_balance VALUES ...(continued)...
(i.e. remove the errant backquote)
If you need an editor that can handle large files, try something like vim.

Resources